* NEW: CompressedBin folder .cbin
* This folder holds compressed versions of what was in .bin
* These files are 7-zip compressed using file + header encryption
* (This is to avoid false-positive AV alerts)
* NEW: Python conversion
* All scripts rewritten / ported to Python
* All PoSH scripts removed
* All scripts adjusted to no longer use vars as a variable
* This is because vars is a built-in function
* Also, slightly more clear as vars_wk == variables for Wizard Kit
* vars_os merged with vars_wk for since both are based on the current system
* Launch.cmd no longer uses %path% and instead directly modifies L_PATH
* fixes bug where an empty %PATH% would halt various scripts
* Copy WizardKit
* Now only copies the required folders in .bin
* Avoids potentially massive slowdowns on often-used UFDs
* Updated to support the new .cbin folder
* User Data Transfer expanded
* File-based main data selection is now done first
* Default inclusions and exclusions adjusted
* Cleanup should now unhide TransferDir
* Launch.cmd and Launchers updated
* Launch and Launcher_Template reworked to support the new .cbin method
* Launch will extract the archive (if exists) and then launch the item
* Launch.cmd now automatically reloads inside ConEmu
* Launch.cmd now runs from L_ITEM's dir in most cases
* Added L_NCMD to use the native command window instead of ConEmu
* Added PywScript mode that uses Python native console window
* Launchers are customized at the top of the files now
* FindBin and Flags functions have been moved to the end of the file
* Launchers and Launch.cmd now use more descriptive variable names
* Helps readability and troubleshooting
* Ported code from copy_office.cmd into Launch.cmd
* Office setup local folders now have better naming
* Scripts should now print details about the ENV when aborting
* Should help diagnose future breaks, typos, etc..
* Added a gen_office.bash script for creating the Office Setup Launchers
* Fixed Office variable issue (needed delayedexpansion)
* SW Diagnostics / SW Checklist
* (Re)added Kill All Processes section using ProcessKiller 2.0 from Tron
* Added Everything - dumps a file listing of the %systemdrive%
* Added Opera to the browser backup section
* AdwCleaner is no longer removed during the checklist
* HWiNFO has replaced HWMonitor due to false AMD/ATI readings
* HWiNFO is not opened until after Enter is pressed to exit the checklist
* Installed OS warnings expanded to mark many more versions as outdated
* SAS is no longer force-removed at the end of the script
* The new user data size function is reading data for all users
96 lines
3.3 KiB
Python
96 lines
3.3 KiB
Python
# Wizard Kit: DISM wrapper
|
|
|
|
import os
|
|
import subprocess
|
|
|
|
# Init
|
|
os.chdir(os.path.dirname(os.path.realpath(__file__)))
|
|
os.system('title Wizard Kit: DISM helper Tool')
|
|
from functions import *
|
|
vars_wk = init_vars_wk()
|
|
vars_wk.update(init_vars_os())
|
|
os.makedirs('{LogDir}'.format(**vars_wk), exist_ok=True)
|
|
vars_wk['LogFile'] = '{LogDir}\\dism_helper.log'.format(**vars_wk)
|
|
|
|
def abort():
|
|
print_warning('Aborted.', vars_wk['LogFile'])
|
|
exit_script()
|
|
|
|
def exit_script():
|
|
pause("Press Enter to exit...")
|
|
quit()
|
|
|
|
def check_health():
|
|
_args = [
|
|
'/Online',
|
|
'/Cleanup-Image',
|
|
'/CheckHealth',
|
|
'/LogPath:{LogDir}\\DISM_CheckHealth.log'.format(**vars_wk)]
|
|
try:
|
|
_result = run_program('dism', _args).stdout.decode()
|
|
except subprocess.CalledProcessError:
|
|
print_error('ERROR: failed to run DISM health check', vars_wk['LogFile'])
|
|
_result = ['Unknown']
|
|
else:
|
|
# Check result
|
|
if re.search(r'No component store corruption detected', _result, re.IGNORECASE):
|
|
return True
|
|
else:
|
|
for line in _result:
|
|
line = ' ' + line
|
|
print_warning(line, vars_wk['LogFile'])
|
|
print_error('ERROR: DISM encountered errors, please review details above', vars_wk['LogFile'])
|
|
return False
|
|
|
|
def restore_health():
|
|
_args = [
|
|
'/Online',
|
|
'/Cleanup-Image',
|
|
'/RestoreHealth',
|
|
'/LogPath:{LogDir}\\DISM_RestoreHealth.log'.format(**vars_wk),
|
|
'-new_console:n',
|
|
'-new_console:s33V']
|
|
run_program('dism', _args, pipe=False, check=False)
|
|
wait_for_process('dism')
|
|
|
|
def scan_health():
|
|
_args = [
|
|
'/Online',
|
|
'/Cleanup-Image',
|
|
'/ScanHealth',
|
|
'/LogPath:{LogDir}\\DISM_ScanHealth.log'.format(**vars_wk),
|
|
'-new_console:n',
|
|
'-new_console:s33V']
|
|
run_program('dism', _args, pipe=False, check=False)
|
|
wait_for_process('dism')
|
|
|
|
if __name__ == '__main__':
|
|
stay_awake(vars_wk)
|
|
if vars_wk['Version'] in ['8', '10']:
|
|
options = [
|
|
{'Name': 'Check Health', 'Command': 'Check'},
|
|
{'Name': 'Restore Health', 'Command': 'Restore'}]
|
|
actions = [{'Name': 'Quit', 'Letter': 'Q'}]
|
|
selection = menu_select('Please select action to perform', options, actions)
|
|
run_program('cls', check=False, pipe=False, shell=True)
|
|
if selection == 'Q':
|
|
abort()
|
|
elif options[int(selection)-1]['Command'] == 'Check':
|
|
print_info('Scanning for component store corruption...', vars_wk['LogFile'])
|
|
scan_health()
|
|
if check_health():
|
|
print_success('No component store corruption detected.', vars_wk['LogFile'])
|
|
elif options[int(selection)-1]['Command'] == 'Restore':
|
|
print_info('Scanning for, and attempting to repair, component store corruption...', vars_wk['LogFile'])
|
|
restore_health()
|
|
if check_health():
|
|
print_success('No component store corruption detected.', vars_wk['LogFile'])
|
|
else:
|
|
abort()
|
|
else:
|
|
# Windows 7 and older
|
|
print_error('ERROR: This tool is not intended for {ProductName}.'.format(**vars_wk), vars_wk['LogFile'])
|
|
|
|
print_success('Done.', vars_wk['LogFile'])
|
|
kill_process('caffeine.exe')
|
|
exit_script()
|