diff --git a/.bin/Scripts/system_diagnostics.py b/.bin/Scripts/system_diagnostics.py index 7ce0f639..c13147d4 100644 --- a/.bin/Scripts/system_diagnostics.py +++ b/.bin/Scripts/system_diagnostics.py @@ -16,7 +16,6 @@ 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 -ERRORS = 0 # Static Variables BLEACH_BIT_CLEANERS = { @@ -68,13 +67,15 @@ BLEACH_BIT_CLEANERS = { def check_result(result, other_results): """Check result for warnings and errors.""" + result_ok = True if not result['CS']: for warning in other_results.get('Warning', {}).keys(): if warning in str(result['Error']): # Ignore warnings and repair statements - return + return True # Error is not a warning - ERRORS += 1 + result_ok = False + return result_ok if __name__ == '__main__': try: @@ -82,6 +83,7 @@ if __name__ == '__main__': clear_screen() print_info('{}: System Diagnostics Tool\n'.format(KIT_NAME_FULL)) ticket_number = get_ticket_number() + system_ok = True other_results = { 'Error': { 'CalledProcessError': 'Unknown Error', @@ -94,7 +96,7 @@ if __name__ == '__main__': if ENABLED_TICKET_NUMBERS: print_info('Starting System Diagnostics for Ticket #{}\n'.format( ticket_number)) - + # Sanitize Environment print_info('Sanitizing Environment') if not D7_MODE: @@ -102,10 +104,10 @@ if __name__ == '__main__': 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 if not D7_MODE: print_info('Starting Background Scans') @@ -114,25 +116,24 @@ if __name__ == '__main__': 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') result = try_and_print( message='CHKDSK ({SYSTEMDRIVE})...'.format(**global_vars['Env']), function=run_chkdsk, other_results=other_results) - check_result(result, other_results) + system_ok &= check_result(result, other_results) result = try_and_print(message='SFC scan...', function=run_sfc_scan, other_results=other_results) - check_result(result, other_results) + system_ok &= check_result(result, other_results) if D7_MODE: result = try_and_print(message='DISM RestoreHealth...', function=run_dism, other_results=other_results, repair=True) - check_result(result, other_results) + system_ok &= check_result(result, other_results) else: try_and_print(message='DISM CheckHealth...', function=run_dism, other_results=other_results, repair=False) - - + if D7_MODE: # Archive all browsers for all users archive_all_users() @@ -140,7 +141,7 @@ if __name__ == '__main__': # Scan for supported browsers print_info('Scanning for browsers') scan_for_browsers() - + # Run BleachBit cleaners print_info('BleachBit Cleanup') for k, v in sorted(BLEACH_BIT_CLEANERS.items()): @@ -148,7 +149,7 @@ if __name__ == '__main__': function=run_bleachbit, cs='Done', other_results=other_results, cleaners=v, preview=bool(not D7_MODE)) - + # Export system info print_info('Backup System Information') try_and_print(message='AIDA64 reports...', @@ -164,7 +165,7 @@ if __name__ == '__main__': if not D7_MODE: try_and_print(message='Registry...', function=backup_registry, cs='Done', other_results=other_results) - + # Summary if not D7_MODE: print_info('Summary') @@ -185,7 +186,7 @@ if __name__ == '__main__': other_results=other_results, print_return=True) try_and_print(message='Product Keys:', function=get_product_keys, ns='Unknown', print_return=True) - + # User data if not D7_MODE: print_info('User Data') @@ -193,7 +194,7 @@ if __name__ == '__main__': show_user_data_summary() except Exception: print_error(' Unknown error.') - + # Done if not D7_MODE or ERRORS > 0: print_standard('\nDone.')