Add "auto_" windows updates functions
This commit is contained in:
parent
078859838a
commit
973dad3240
3 changed files with 46 additions and 5 deletions
|
|
@ -56,13 +56,13 @@ BASE_MENUS = {
|
||||||
MenuEntry('Enable System Restore', 'auto_system_restore_enable'),
|
MenuEntry('Enable System Restore', 'auto_system_restore_enable'),
|
||||||
MenuEntry('Set System Restore Size', 'auto_system_restore_set_size'),
|
MenuEntry('Set System Restore Size', 'auto_system_restore_set_size'),
|
||||||
MenuEntry('Create System Restore', 'auto_system_restore_create'),
|
MenuEntry('Create System Restore', 'auto_system_restore_create'),
|
||||||
MenuEntry('Backup Browsers', placeholder_function),
|
#MenuEntry('Backup Browsers', #TODO),
|
||||||
MenuEntry('Backup Power Plans', 'auto_backup_power_plans'),
|
MenuEntry('Backup Power Plans', 'auto_backup_power_plans'),
|
||||||
MenuEntry('Backup Registry', 'auto_backup_registry'),
|
MenuEntry('Backup Registry', 'auto_backup_registry'),
|
||||||
),
|
),
|
||||||
'Windows Repairs': (
|
'Windows Repairs': (
|
||||||
MenuEntry('Disable Windows Updates', placeholder_function),
|
MenuEntry('Disable Windows Updates', 'auto_windows_updates_disable'),
|
||||||
MenuEntry('Reset Windows Updates', placeholder_function),
|
MenuEntry('Reset Windows Updates', 'auto_windows_updates_reset'),
|
||||||
MenuEntry('Reboot', placeholder_reboot),
|
MenuEntry('Reboot', placeholder_reboot),
|
||||||
MenuEntry('CHKDSK', placeholder_function),
|
MenuEntry('CHKDSK', placeholder_function),
|
||||||
MenuEntry('DISM RestoreHealth', 'auto_dism'),
|
MenuEntry('DISM RestoreHealth', 'auto_dism'),
|
||||||
|
|
@ -85,7 +85,7 @@ BASE_MENUS = {
|
||||||
'Manual Steps': (
|
'Manual Steps': (
|
||||||
MenuEntry('AdwCleaner', placeholder_function),
|
MenuEntry('AdwCleaner', placeholder_function),
|
||||||
MenuEntry('IO Bit Uninstaller', placeholder_function),
|
MenuEntry('IO Bit Uninstaller', placeholder_function),
|
||||||
MenuEntry('Enable Windows Updates', placeholder_function),
|
MenuEntry('Enable Windows Updates', 'auto_windows_updates_enable'),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
'Options': (
|
'Options': (
|
||||||
|
|
|
||||||
|
|
@ -192,5 +192,11 @@ def recursive_copy(source, dest, overwrite=False):
|
||||||
raise FileExistsError(f'Refusing to delete file: {dest}')
|
raise FileExistsError(f'Refusing to delete file: {dest}')
|
||||||
|
|
||||||
|
|
||||||
|
def rename_item(path, new_path):
|
||||||
|
"""Rename item, returns pathlib.Path."""
|
||||||
|
path = pathlib.Path(path)
|
||||||
|
return path.rename(new_path)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
print("This file is not meant to be called directly.")
|
print("This file is not meant to be called directly.")
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ from subprocess import CalledProcessError, DEVNULL
|
||||||
|
|
||||||
from wk.cfg.main import KIT_NAME_FULL
|
from wk.cfg.main import KIT_NAME_FULL
|
||||||
from wk.exe import get_procs, run_program, popen_program, wait_for_procs
|
from wk.exe import get_procs, run_program, popen_program, wait_for_procs
|
||||||
|
from wk.io import delete_folder, rename_item
|
||||||
from wk.kit.tools import run_tool
|
from wk.kit.tools import run_tool
|
||||||
from wk.log import format_log_path, update_log_path
|
from wk.log import format_log_path, update_log_path
|
||||||
from wk.os.win import (
|
from wk.os.win import (
|
||||||
|
|
@ -516,6 +517,30 @@ def auto_system_restore_set_size(group, name):
|
||||||
save_settings(group, name, result=result)
|
save_settings(group, name, result=result)
|
||||||
|
|
||||||
|
|
||||||
|
def auto_windows_updates_disable(group, name):
|
||||||
|
"""Disable Windows Updates."""
|
||||||
|
result = TRY_PRINT.run('Disable Windows Updates...', disable_windows_updates)
|
||||||
|
if result['Failed']:
|
||||||
|
# Reboot and try again?
|
||||||
|
reboot()
|
||||||
|
save_settings(group, name, result=result)
|
||||||
|
|
||||||
|
|
||||||
|
def auto_windows_updates_enable(group, name):
|
||||||
|
"""Enable Windows Updates."""
|
||||||
|
result = TRY_PRINT.run('Enable Windows Updates...', enable_windows_updates)
|
||||||
|
save_settings(group, name, result=result)
|
||||||
|
|
||||||
|
|
||||||
|
def auto_windows_updates_reset(group, name):
|
||||||
|
"""Reset Windows Updates."""
|
||||||
|
result = TRY_PRINT.run('Reset Windows Updates...', reset_windows_updates)
|
||||||
|
if result['Failed']:
|
||||||
|
# Reboot and try again?
|
||||||
|
reboot()
|
||||||
|
save_settings(group, name, result=result)
|
||||||
|
|
||||||
|
|
||||||
# Misc Functions
|
# Misc Functions
|
||||||
def set_backup_path(name, date=False):
|
def set_backup_path(name, date=False):
|
||||||
"""Set backup path, returns pathlib.Path."""
|
"""Set backup path, returns pathlib.Path."""
|
||||||
|
|
@ -551,8 +576,8 @@ def create_system_restore_point():
|
||||||
|
|
||||||
def disable_windows_updates():
|
def disable_windows_updates():
|
||||||
"""Disable and stop Windows Updates."""
|
"""Disable and stop Windows Updates."""
|
||||||
stop_service('wuauserv')
|
|
||||||
disable_service('wuauserv')
|
disable_service('wuauserv')
|
||||||
|
stop_service('wuauserv')
|
||||||
|
|
||||||
|
|
||||||
def enable_windows_updates():
|
def enable_windows_updates():
|
||||||
|
|
@ -601,6 +626,16 @@ def reboot(timeout=10):
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
|
||||||
|
def reset_windows_updates():
|
||||||
|
"""Reset Windows Updates."""
|
||||||
|
system_root = os.environ.get('SYSTEMROOT', 'C:/Windows')
|
||||||
|
rename_item(
|
||||||
|
f'{system_root}/SoftwareDistribution',
|
||||||
|
f'{system_root}/SoftwareDistribution.old',
|
||||||
|
)
|
||||||
|
delete_folder(f'{system_root}/SoftwareDistribution.old', force=True)
|
||||||
|
|
||||||
|
|
||||||
def run_chkdsk_offline():
|
def run_chkdsk_offline():
|
||||||
"""Set filesystem 'dirty bit' to force a CHKDSK during startup."""
|
"""Set filesystem 'dirty bit' to force a CHKDSK during startup."""
|
||||||
cmd = ['fsutil', 'dirty', 'set', os.environ.get('SYSTEMDRIVE', 'C:')]
|
cmd = ['fsutil', 'dirty', 'set', os.environ.get('SYSTEMDRIVE', 'C:')]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue