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