Set wuauserv startup to manual when enabling
* This is the default in at Windows 10 * Fixes issue #46
This commit is contained in:
parent
f39bb8191e
commit
a7926e58a4
1 changed files with 8 additions and 8 deletions
|
|
@ -66,12 +66,9 @@ def disable_windows_updates():
|
|||
raise GenericError('Failed to remove folder {}'.format(folder_path))
|
||||
|
||||
|
||||
def enable_service(service_name):
|
||||
"""Set service startup to enabled."""
|
||||
try:
|
||||
run_program(['sc', 'config', service_name, 'start=', 'automatic'])
|
||||
except subprocess.CalledProcessError:
|
||||
run_program(['sc', 'config', service_name, 'start=', 'auto'])
|
||||
def enable_service(service_name, start_type='auto'):
|
||||
"""Enable service by setting start type."""
|
||||
run_program(['sc', 'config', service_name, 'start=', start_type])
|
||||
|
||||
|
||||
def enable_windows_updates():
|
||||
|
|
@ -81,15 +78,18 @@ def enable_windows_updates():
|
|||
|
||||
for service in ('bits', 'wuauserv'):
|
||||
# Enable service
|
||||
start_type = 'auto'
|
||||
if service == 'wuauserv':
|
||||
start_type = 'demand'
|
||||
result = try_and_print(
|
||||
'Enabling service {}...'.format(service),
|
||||
indent=indent, width=width,
|
||||
function=enable_service, service_name=service)
|
||||
function=enable_service, service_name=service, start_type=start_type)
|
||||
if not result['CS']:
|
||||
result = try_and_print(
|
||||
'Enabling service {}...'.format(service),
|
||||
indent=indent, width=width,
|
||||
function=enable_service, service_name=service)
|
||||
function=enable_service, service_name=service, start_type=start_type)
|
||||
if not result['CS']:
|
||||
raise GenericError('Service {} could not be enabled.'.format(service))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue