Updated system checklist/diags and user checklits
* Added D7_MODE to limit functions run during d7II * Added new archive_all_users() function to be run in system_diagnostics
This commit is contained in:
parent
71297eacc8
commit
ed3323fffb
4 changed files with 139 additions and 68 deletions
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
from functions.common import *
|
||||
|
||||
from operator import itemgetter
|
||||
|
||||
# Define other_results for later try_and_print
|
||||
browser_data = {}
|
||||
other_results = {
|
||||
|
|
@ -98,11 +100,57 @@ SUPPORTED_BROWSERS = {
|
|||
},
|
||||
}
|
||||
|
||||
def archive_all_users():
|
||||
"""Create backups for all browsers for all users."""
|
||||
users_root = r'{}\Users'.format(global_vars['Env']['SYSTEMDRIVE'])
|
||||
user_envs = []
|
||||
|
||||
# Build list of valid users
|
||||
for user_name in os.listdir(users_root):
|
||||
valid_user = True
|
||||
if user_name in ('Default', 'Default User'):
|
||||
# Skip default users
|
||||
continue
|
||||
user_path = os.path.join(users_root, user_name)
|
||||
appdata_local = os.path.join(user_path, r'AppData\Local')
|
||||
appdata_roaming = os.path.join(user_path, r'AppData\Roaming')
|
||||
valid_user &= os.path.exists(appdata_local)
|
||||
valid_user &= os.path.exists(appdata_roaming)
|
||||
if valid_user:
|
||||
user_envs.append({
|
||||
'USERNAME': user_name,
|
||||
'USERPROFILE': user_path,
|
||||
'APPDATA': appdata_roaming,
|
||||
'LOCALAPPDATA': appdata_local})
|
||||
|
||||
# Backup browsers for all valid users
|
||||
print_info('Backing up browsers')
|
||||
for fake_env in sorted(user_envs, key=itemgetter('USERPROFILE')):
|
||||
print_standard(fake_env['USERNAME'])
|
||||
for b_k, b_v in sorted(SUPPORTED_BROWSERS.items()):
|
||||
if b_k == 'Mozilla Firefox Dev':
|
||||
continue
|
||||
source_path = b_v['user_data_path'].format(**fake_env)
|
||||
if not os.path.exists(source_path):
|
||||
continue
|
||||
source_items = source_path + '*'
|
||||
archive_path = r'{BackupDir}\Browsers ({USERNAME})'.format(
|
||||
**global_vars, **fake_env)
|
||||
os.makedirs(archive_path, exist_ok=True)
|
||||
archive_path += r'\{}.7z'.format(b_k)
|
||||
cmd = [
|
||||
global_vars['Tools']['SevenZip'],
|
||||
'a', '-aoa', '-bso0', '-bse0', '-mx=1',
|
||||
archive_path, source_items]
|
||||
try_and_print(message=' {}...'.format(b_k),
|
||||
function=run_program, cmd=cmd)
|
||||
print_standard(' ')
|
||||
|
||||
def archive_browser(name):
|
||||
"""Create backup of Browser saved in the BackupDir."""
|
||||
source = '{}*'.format(browser_data[name]['user_data_path'])
|
||||
dest = r'{BackupDir}\Browsers ({USERNAME})'.format(
|
||||
**global_vars, **global_vars['Env'])
|
||||
**global_vars, **env)
|
||||
archive = r'{}\{}.7z'.format(dest, name)
|
||||
os.makedirs(dest, exist_ok=True)
|
||||
cmd = [
|
||||
|
|
@ -135,7 +183,7 @@ def clean_chromium_profile(profile):
|
|||
|
||||
def clean_internet_explorer(**kwargs):
|
||||
"""Uses the built-in function to reset IE and sets the homepage.
|
||||
|
||||
|
||||
NOTE: kwargs set but unused as a workaround."""
|
||||
kill_process('iexplore.exe')
|
||||
run_program(['rundll32.exe', 'inetcpl.cpl,ResetIEtoDefaults'], check=False)
|
||||
|
|
@ -179,11 +227,11 @@ def clean_mozilla_profile(profile):
|
|||
def get_browser_details(name):
|
||||
"""Get installation status and profile details for all supported browsers."""
|
||||
browser = SUPPORTED_BROWSERS[name].copy()
|
||||
|
||||
|
||||
# Update user_data_path
|
||||
browser['user_data_path'] = browser['user_data_path'].format(
|
||||
**global_vars['Env'])
|
||||
|
||||
|
||||
# Find executable (if multiple files are found, the last one is used)
|
||||
exe_path = None
|
||||
num_installs = 0
|
||||
|
|
@ -194,7 +242,7 @@ def get_browser_details(name):
|
|||
if os.path.exists(test_path):
|
||||
num_installs += 1
|
||||
exe_path = test_path
|
||||
|
||||
|
||||
# Find profile(s)
|
||||
profiles = []
|
||||
if browser['base'] == 'ie':
|
||||
|
|
@ -227,7 +275,7 @@ def get_browser_details(name):
|
|||
if os.path.exists(browser['user_data_path']):
|
||||
profiles.append(
|
||||
{'name': 'Default', 'path': browser['user_data_path']})
|
||||
|
||||
|
||||
# Get homepages
|
||||
if browser['base'] == 'ie':
|
||||
# IE is set to only have one profile above
|
||||
|
|
@ -236,14 +284,14 @@ def get_browser_details(name):
|
|||
for profile in profiles:
|
||||
prefs_path = r'{path}\prefs.js'.format(**profile)
|
||||
profile['homepages'] = get_mozilla_homepages(prefs_path=prefs_path)
|
||||
|
||||
|
||||
# Add to browser_data
|
||||
browser_data[name] = browser
|
||||
browser_data[name].update({
|
||||
'exe_path': exe_path,
|
||||
'profiles': profiles,
|
||||
})
|
||||
|
||||
|
||||
# Raise installation warnings (if any)
|
||||
if num_installs == 0:
|
||||
raise NotInstalledError
|
||||
|
|
@ -299,7 +347,7 @@ def get_mozilla_homepages(prefs_path):
|
|||
homepages = search.group(1).split('|')
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
return homepages
|
||||
|
||||
def get_mozilla_profiles(search_path, dev=False):
|
||||
|
|
@ -391,7 +439,7 @@ def install_adblock(indent=8, width=32):
|
|||
|
||||
def list_homepages(indent=8, width=32):
|
||||
"""List current homepages for reference."""
|
||||
|
||||
|
||||
for browser in [k for k, v in sorted(browser_data.items()) if v['exe_path']]:
|
||||
# Skip Chromium-based browsers
|
||||
if browser_data[browser]['base'] == 'chromium':
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ from functions.setup import *
|
|||
init_global_vars()
|
||||
os.system('title {}: System Checklist Tool'.format(KIT_NAME_FULL))
|
||||
global_vars['LogFile'] = r'{LogDir}\System Checklist.log'.format(**global_vars)
|
||||
D7_MODE = 'd7mode' in sys.argv
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
|
|
@ -49,17 +50,18 @@ if __name__ == '__main__':
|
|||
function=cleanup_adwcleaner, cs='Done', other_results=other_results)
|
||||
|
||||
# Export system info
|
||||
print_info('Backup System Information')
|
||||
try_and_print(message='AIDA64 reports...',
|
||||
function=run_aida64, cs='Done', other_results=other_results)
|
||||
try_and_print(message='File listing...',
|
||||
function=backup_file_list, cs='Done', other_results=other_results)
|
||||
try_and_print(message='Power plans...',
|
||||
function=backup_power_plans, cs='Done')
|
||||
try_and_print(message='Product Keys...', other_results=other_results,
|
||||
function=run_produkey, cs='Done')
|
||||
try_and_print(message='Registry...',
|
||||
function=backup_registry, cs='Done', other_results=other_results)
|
||||
if not D7_MODE:
|
||||
print_info('Backup System Information')
|
||||
try_and_print(message='AIDA64 reports...',
|
||||
function=run_aida64, cs='Done', other_results=other_results)
|
||||
try_and_print(message='File listing...',
|
||||
function=backup_file_list, cs='Done', other_results=other_results)
|
||||
try_and_print(message='Power plans...',
|
||||
function=backup_power_plans, cs='Done')
|
||||
try_and_print(message='Product Keys...', other_results=other_results,
|
||||
function=run_produkey, cs='Done')
|
||||
try_and_print(message='Registry...',
|
||||
function=backup_registry, cs='Done', other_results=other_results)
|
||||
|
||||
# User data
|
||||
print_info('User Data')
|
||||
|
|
@ -79,12 +81,18 @@ if __name__ == '__main__':
|
|||
try_and_print(message='Installed RAM:',
|
||||
function=show_installed_ram, ns='Unknown', silent_function=False)
|
||||
show_free_space()
|
||||
if D7_MODE:
|
||||
try_and_print(message='Temp Size:',
|
||||
function=show_temp_files_size, silent_function=False)
|
||||
try_and_print(message='Installed Antivirus:',
|
||||
function=get_installed_antivirus, ns='Unknown',
|
||||
other_results=other_results, print_return=True)
|
||||
try_and_print(message='Installed Office:',
|
||||
function=get_installed_office, ns='Unknown',
|
||||
other_results=other_results, print_return=True)
|
||||
if D7_MODE:
|
||||
try_and_print(message='Product Keys:',
|
||||
function=get_product_keys, ns='Unknown', print_return=True)
|
||||
|
||||
# Play audio, show devices, open Windows updates, and open Activation
|
||||
try_and_print(message='Opening Device Manager...',
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ init_global_vars()
|
|||
os.system('title {}: System Diagnostics Tool'.format(KIT_NAME_FULL))
|
||||
global_vars['LogFile'] = r'{LogDir}\System Diagnostics.log'.format(
|
||||
**global_vars)
|
||||
D7_MODE = 'd7mode' in sys.argv
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
|
|
@ -37,23 +38,23 @@ if __name__ == '__main__':
|
|||
|
||||
# Sanitize Environment
|
||||
print_info('Sanitizing Environment')
|
||||
# try_and_print(message='Killing processes...',
|
||||
# function=run_process_killer, cs='Done')
|
||||
try_and_print(message='Running RKill...',
|
||||
function=run_rkill, cs='Done', other_results=other_results)
|
||||
try_and_print(message='Running TDSSKiller...',
|
||||
function=run_tdsskiller, cs='Done', other_results=other_results)
|
||||
if not D7_MODE:
|
||||
try_and_print(message='Running RKill...',
|
||||
function=run_rkill, cs='Done', other_results=other_results)
|
||||
try_and_print(message='Running TDSSKiller...',
|
||||
function=run_tdsskiller, cs='Done', other_results=other_results)
|
||||
|
||||
# Re-run if earlier process was stopped.
|
||||
stay_awake()
|
||||
|
||||
# Start diags
|
||||
print_info('Starting Background Scans')
|
||||
check_connection()
|
||||
try_and_print(message='Running HitmanPro...',
|
||||
function=run_hitmanpro, cs='Started', other_results=other_results)
|
||||
try_and_print(message='Running Autoruns...',
|
||||
function=run_autoruns, cs='Started', other_results=other_results)
|
||||
if not D7_MODE:
|
||||
print_info('Starting Background Scans')
|
||||
check_connection()
|
||||
try_and_print(message='Running HitmanPro...',
|
||||
function=run_hitmanpro, cs='Started', other_results=other_results)
|
||||
try_and_print(message='Running Autoruns...',
|
||||
function=run_autoruns, cs='Started', other_results=other_results)
|
||||
|
||||
# OS Health Checks
|
||||
print_info('OS Health Checks')
|
||||
|
|
@ -65,9 +66,14 @@ if __name__ == '__main__':
|
|||
try_and_print(message='DISM CheckHealth...',
|
||||
function=run_dism, other_results=other_results, repair=False)
|
||||
|
||||
# Scan for supported browsers
|
||||
print_info('Scanning for browsers')
|
||||
scan_for_browsers()
|
||||
|
||||
if D7_MODE:
|
||||
# Archive all browsers for all users
|
||||
archive_all_users()
|
||||
else:
|
||||
# Scan for supported browsers
|
||||
print_info('Scanning for browsers')
|
||||
scan_for_browsers()
|
||||
|
||||
# Export system info
|
||||
print_info('Backup System Information')
|
||||
|
|
@ -75,46 +81,51 @@ if __name__ == '__main__':
|
|||
function=run_aida64, cs='Done', other_results=other_results)
|
||||
try_and_print(message='BleachBit report...',
|
||||
function=run_bleachbit, cs='Done', other_results=other_results)
|
||||
backup_browsers()
|
||||
if not D7_MODE:
|
||||
backup_browsers()
|
||||
try_and_print(message='File listing...',
|
||||
function=backup_file_list, cs='Done', other_results=other_results)
|
||||
try_and_print(message='Power plans...',
|
||||
function=backup_power_plans, cs='Done')
|
||||
try_and_print(message='Product Keys...',
|
||||
function=run_produkey, cs='Done', other_results=other_results)
|
||||
try_and_print(message='Registry...',
|
||||
function=backup_registry, cs='Done', other_results=other_results)
|
||||
if not D7_MODE:
|
||||
try_and_print(message='Registry...',
|
||||
function=backup_registry, cs='Done', other_results=other_results)
|
||||
|
||||
# Summary
|
||||
print_info('Summary')
|
||||
try_and_print(message='Operating System:',
|
||||
function=show_os_name, ns='Unknown', silent_function=False)
|
||||
try_and_print(message='Activation:',
|
||||
function=show_os_activation, ns='Unknown', silent_function=False)
|
||||
try_and_print(message='Installed RAM:',
|
||||
function=show_installed_ram, ns='Unknown', silent_function=False)
|
||||
show_free_space()
|
||||
try_and_print(message='Temp Size:',
|
||||
function=show_temp_files_size, silent_function=False)
|
||||
try_and_print(message='Installed Antivirus:',
|
||||
function=get_installed_antivirus, ns='Unknown',
|
||||
other_results=other_results, print_return=True)
|
||||
try_and_print(message='Installed Office:',
|
||||
function=get_installed_office, ns='Unknown',
|
||||
other_results=other_results, print_return=True)
|
||||
try_and_print(message='Product Keys:',
|
||||
function=get_product_keys, ns='Unknown', print_return=True)
|
||||
if not D7_MODE:
|
||||
print_info('Summary')
|
||||
try_and_print(message='Operating System:',
|
||||
function=show_os_name, ns='Unknown', silent_function=False)
|
||||
try_and_print(message='Activation:',
|
||||
function=show_os_activation, ns='Unknown', silent_function=False)
|
||||
try_and_print(message='Installed RAM:',
|
||||
function=show_installed_ram, ns='Unknown', silent_function=False)
|
||||
show_free_space()
|
||||
try_and_print(message='Temp Size:',
|
||||
function=show_temp_files_size, silent_function=False)
|
||||
try_and_print(message='Installed Antivirus:',
|
||||
function=get_installed_antivirus, ns='Unknown',
|
||||
other_results=other_results, print_return=True)
|
||||
try_and_print(message='Installed Office:',
|
||||
function=get_installed_office, ns='Unknown',
|
||||
other_results=other_results, print_return=True)
|
||||
try_and_print(message='Product Keys:',
|
||||
function=get_product_keys, ns='Unknown', print_return=True)
|
||||
|
||||
# User data
|
||||
print_info('User Data')
|
||||
try:
|
||||
show_user_data_summary()
|
||||
except Exception:
|
||||
print_error(' Unknown error.')
|
||||
if not D7_MODE:
|
||||
print_info('User Data')
|
||||
try:
|
||||
show_user_data_summary()
|
||||
except Exception:
|
||||
print_error(' Unknown error.')
|
||||
|
||||
# Done
|
||||
print_standard('\nDone.')
|
||||
pause('Press Enter to exit...')
|
||||
if not D7_MODE:
|
||||
print_standard('\nDone.')
|
||||
pause('Press Enter to exit...')
|
||||
exit_script()
|
||||
except SystemExit:
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ init_global_vars()
|
|||
os.system('title {}: User Checklist Tool'.format(KIT_NAME_FULL))
|
||||
global_vars['LogFile'] = r'{LogDir}\User Checklist ({USERNAME}).log'.format(
|
||||
**global_vars, **global_vars['Env'])
|
||||
D7_MODE = 'd7mode' in sys.argv
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
|
|
@ -46,8 +47,10 @@ if __name__ == '__main__':
|
|||
list_homepages()
|
||||
|
||||
# Backup
|
||||
print_info('Backing up browsers')
|
||||
backup_browsers()
|
||||
if not D7_MODE:
|
||||
# Done during system_diagnostics
|
||||
print_info('Backing up browsers')
|
||||
backup_browsers()
|
||||
|
||||
# Reset
|
||||
if answer_config_browsers and answer_reset_browsers:
|
||||
|
|
@ -77,8 +80,9 @@ if __name__ == '__main__':
|
|||
popen_program(['start', '', 'https://fast.com'], shell=True)
|
||||
|
||||
# Done
|
||||
print_standard('\nDone.')
|
||||
pause('Press Enter to exit...')
|
||||
if not D7_MODE:
|
||||
print_standard('\nDone.')
|
||||
pause('Press Enter to exit...')
|
||||
exit_script()
|
||||
except SystemExit:
|
||||
pass
|
||||
|
|
|
|||
Loading…
Reference in a new issue