Try renaming update folder(s) if deletion fails

This commit is contained in:
2Shirt 2019-11-15 16:07:00 -07:00
parent 54654a73bd
commit ae475a04f2
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C

View file

@ -1,5 +1,7 @@
# Wizard Kit: Functions - Windows updates
import pathlib
from functions.common import *
@ -63,7 +65,11 @@ def disable_windows_updates():
indent=indent, width=width,
function=delete_folder, folder_path=folder_path)
if not result['CS']:
raise GenericError('Failed to remove folder {}'.format(folder_path))
try:
new_path = pathlib.path(folder_path).with_suffix('.bak')
os.rename(folder_path, new_path)
except OSError:
raise GenericError('Failed to remove folder {}'.format(folder_path))
def enable_service(service_name, start_type='auto'):