|
|
@ -22,9 +22,9 @@ |
|
|
|
|
|
|
|
|
|
|
|
void ITask.Run(ILogger logger) |
|
|
|
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 |
|
|
|
try |
|
|
|
{ |
|
|
|
{ |
|
|
|
var disabledStatus = DeviceHelper.IsDeviceCurrentlyDisabled(device); |
|
|
|
var disabledStatus = DeviceHelper.IsDeviceCurrentlyDisabled(device); |
|
|
@ -32,19 +32,18 @@ |
|
|
|
{ |
|
|
|
{ |
|
|
|
logger.Log("Device not present"); |
|
|
|
logger.Log("Device not present"); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (!disabledStatus.Value) |
|
|
|
else if (disabledStatus.Value) |
|
|
|
{ |
|
|
|
{ |
|
|
|
logger.Log("Device enabled; attempting to disable..."); |
|
|
|
logger.Log("Device disabled; attempting to enable..."); |
|
|
|
DeviceHelper.DisableDevice(device); |
|
|
|
DeviceHelper.EnableDevice(device); |
|
|
|
logger.Log("Disabled device; checking status..."); |
|
|
|
logger.Log("Enabled device; checking status..."); |
|
|
|
var newStatus = DeviceHelper.IsDeviceCurrentlyDisabled(device); |
|
|
|
var newStatus = DeviceHelper.IsDeviceCurrentlyDisabled(device); |
|
|
|
if (!newStatus.HasValue) |
|
|
|
if (!newStatus.HasValue) |
|
|
|
{ |
|
|
|
{ |
|
|
|
logger.LogError("Device not present"); |
|
|
|
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 |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
@ -53,7 +52,7 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
logger.Log("Device is disabled"); |
|
|
|
logger.Log("Device is enabled"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception e) |
|
|
|
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 |
|
|
|
try |
|
|
|
{ |
|
|
|
{ |
|
|
|
var disabledStatus = DeviceHelper.IsDeviceCurrentlyDisabled(device); |
|
|
|
var disabledStatus = DeviceHelper.IsDeviceCurrentlyDisabled(device); |
|
|
@ -72,18 +71,19 @@ |
|
|
|
{ |
|
|
|
{ |
|
|
|
logger.Log("Device not present"); |
|
|
|
logger.Log("Device not present"); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (disabledStatus.Value) |
|
|
|
else if (!disabledStatus.Value) |
|
|
|
{ |
|
|
|
{ |
|
|
|
logger.Log("Device disabled; attempting to enable..."); |
|
|
|
logger.Log("Device enabled; attempting to disable..."); |
|
|
|
DeviceHelper.EnableDevice(device); |
|
|
|
DeviceHelper.DisableDevice(device); |
|
|
|
logger.Log("Enabled device; checking status..."); |
|
|
|
logger.Log("Disabled device; checking status..."); |
|
|
|
var newStatus = DeviceHelper.IsDeviceCurrentlyDisabled(device); |
|
|
|
var newStatus = DeviceHelper.IsDeviceCurrentlyDisabled(device); |
|
|
|
if (!newStatus.HasValue) |
|
|
|
if (!newStatus.HasValue) |
|
|
|
{ |
|
|
|
{ |
|
|
|
logger.LogError("Device not present"); |
|
|
|
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 |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
@ -92,7 +92,7 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
logger.Log("Device is enabled"); |
|
|
|
logger.Log("Device is disabled"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception e) |
|
|
|
catch (Exception e) |
|
|
|