diff --git a/.bin/Scripts/functions/windows_updates.py b/.bin/Scripts/functions/windows_updates.py index ee7ec279..36a390ad 100644 --- a/.bin/Scripts/functions/windows_updates.py +++ b/.bin/Scripts/functions/windows_updates.py @@ -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))