|
|
|
@ -22,9 +22,9 @@ |
|
|
|
|
|
|
|
|
|
void ITask.Run(ILogger logger) |
|
|
|
|
{ |
|
|
|
|
foreach (var device in this.StartupDevicesStatus.EnabledDevices) |
|
|
|
|
foreach (var device in this.StartupDevicesStatus.DisabledDevices) |
|
|
|
|
{ |
|
|
|
|
logger.Log($"Processing {device.Description}; should be disabled"); |
|
|
|
|
logger.Log($"Processing {device.Description}; should be enabled"); |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
var disabledStatus = DeviceHelper.IsDeviceCurrentlyDisabled(device); |
|
|
|
@ -32,19 +32,18 @@ |
|
|
|
|
{ |
|
|
|
|
logger.Log("Device not present"); |
|
|
|
|
} |
|
|
|
|
else if (!disabledStatus.Value) |
|
|
|
|
else if (disabledStatus.Value) |
|
|
|
|
{ |
|
|
|
|
logger.Log("Device enabled; attempting to disable..."); |
|
|
|
|
DeviceHelper.DisableDevice(device); |
|
|
|
|
logger.Log("Disabled device; checking status..."); |
|
|
|
|
logger.Log("Device disabled; attempting to enable..."); |
|
|
|
|
DeviceHelper.EnableDevice(device); |
|
|
|
|
logger.Log("Enabled device; checking status..."); |
|
|
|
|
var newStatus = DeviceHelper.IsDeviceCurrentlyDisabled(device); |
|
|
|
|
if (!newStatus.HasValue) |
|
|
|
|
{ |
|
|
|
|
logger.LogError("Device not present"); |
|
|
|
|
} |
|
|
|
|
else if (!newStatus.Value) |
|
|
|
|
} else if (newStatus.Value) |
|
|
|
|
{ |
|
|
|
|
logger.LogError("Device is enabled but should be disabled"); |
|
|
|
|
logger.LogError("Device is disabled but should be enabled"); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
@ -53,7 +52,7 @@ |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
logger.Log("Device is disabled"); |
|
|
|
|
logger.Log("Device is enabled"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
catch (Exception e) |
|
|
|
@ -62,9 +61,9 @@ |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
foreach (var device in this.StartupDevicesStatus.DisabledDevices) |
|
|
|
|
foreach (var device in this.StartupDevicesStatus.EnabledDevices) |
|
|
|
|
{ |
|
|
|
|
logger.Log($"Processing {device.Description}; should be enabled"); |
|
|
|
|
logger.Log($"Processing {device.Description}; should be disabled"); |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
var disabledStatus = DeviceHelper.IsDeviceCurrentlyDisabled(device); |
|
|
|
@ -72,18 +71,19 @@ |
|
|
|
|
{ |
|
|
|
|
logger.Log("Device not present"); |
|
|
|
|
} |
|
|
|
|
else if (disabledStatus.Value) |
|
|
|
|
else if (!disabledStatus.Value) |
|
|
|
|
{ |
|
|
|
|
logger.Log("Device disabled; attempting to enable..."); |
|
|
|
|
DeviceHelper.EnableDevice(device); |
|
|
|
|
logger.Log("Enabled device; checking status..."); |
|
|
|
|
logger.Log("Device enabled; attempting to disable..."); |
|
|
|
|
DeviceHelper.DisableDevice(device); |
|
|
|
|
logger.Log("Disabled device; checking status..."); |
|
|
|
|
var newStatus = DeviceHelper.IsDeviceCurrentlyDisabled(device); |
|
|
|
|
if (!newStatus.HasValue) |
|
|
|
|
{ |
|
|
|
|
logger.LogError("Device not present"); |
|
|
|
|
} else if (newStatus.Value) |
|
|
|
|
} |
|
|
|
|
else if (!newStatus.Value) |
|
|
|
|
{ |
|
|
|
|
logger.LogError("Device is disabled but should be enabled"); |
|
|
|
|
logger.LogError("Device is enabled but should be disabled"); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
@ -92,7 +92,7 @@ |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
logger.Log("Device is enabled"); |
|
|
|
|
logger.Log("Device is disabled"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
catch (Exception e) |
|
|
|
|