diff --git a/.bin/Scripts/functions/setup.py b/.bin/Scripts/functions/setup.py index 8cc3fb60..7ca76b52 100644 --- a/.bin/Scripts/functions/setup.py +++ b/.bin/Scripts/functions/setup.py @@ -356,20 +356,33 @@ def install_firefox_extensions(): run_program(cmd) -def install_ninite_bundle(mse=False): +def install_ninite_bundle(mse=False, libreoffice=False): + """Run Ninite installer(s), returns list of Popen objects.""" """Run Ninite file(s) based on OS version.""" + popen_objects = [] if global_vars['OS']['Version'] in ('8', '8.1', '10'): # Modern selection - popen_program(r'{BaseDir}\Installers\Extras\Bundles\Modern.exe'.format( - **global_vars)) + popen_objects.append( + popen_program(r'{BaseDir}\Installers\Extras\Bundles\Modern.exe'.format( + **global_vars))) else: # Legacy selection if mse: cmd = r'{BaseDir}\Installers\Extras\Security'.format(**global_vars) cmd += r'\Microsoft Security Essentials.exe' - popen_program(cmd) - popen_program(r'{BaseDir}\Installers\Extras\Bundles\Legacy.exe'.format( - **global_vars)) + popen_objects.append(popen_program(cmd)) + popen_objects.append( + popen_program(r'{BaseDir}\Installers\Extras\Bundles\Legacy.exe'.format( + **global_vars))) + + # LibreOffice + if libreoffice: + cmd = r'{BaseDir}\Installers\Extras\Office'.format(**global_vars) + cmd += r'\LibreOffice.exe' + popen_objects.append(popen_program(cmd)) + + # Done + return popen_objects def install_vcredists(): diff --git a/.bin/Scripts/functions/sw_diags.py b/.bin/Scripts/functions/sw_diags.py index 8faa25b7..d5a74060 100644 --- a/.bin/Scripts/functions/sw_diags.py +++ b/.bin/Scripts/functions/sw_diags.py @@ -41,6 +41,39 @@ def check_connection(): abort() +def check_for_outdated_os(show_alert=False): + """Checks if the current OS is supported, returns bool. + + NOTE: Preview Builds are considered outdated even if newer than + the latest stable release. This is done for simplicity and + because preview builds are only valid for a short timeframe. + """ + msg = '' + needs_updated = False + preview_build = False + + # Check OS version/notes + os_info = global_vars['OS'].copy() + if os_info['Notes'] == 'unsupported': + needs_updated = True + elif os_info['Version'] == '10' and os_info['Notes'] == 'preview build': + preview_build = True + elif os_info['Version'] == '10' and os_info['Notes'] == 'outdated': + needs_updated = True + + # Show alert + if preview_build: + msg = 'Preview builds are not officially supported' + elif needs_updated: + msg = 'The installed version of Windows is outdated' + if msg and show_alert: + msg += '\n\nPlease consider upgrading before continuing setup.' + show_alert_box(msg) + + # Done + return needs_updated or preview_build + + def check_secure_boot_status(show_alert=False): """Checks UEFI Secure Boot status via PowerShell.""" boot_mode = get_boot_mode() diff --git a/.bin/Scripts/new_system_setup.py b/.bin/Scripts/new_system_setup.py new file mode 100644 index 00000000..42005ba9 --- /dev/null +++ b/.bin/Scripts/new_system_setup.py @@ -0,0 +1,181 @@ +# Wizard Kit: New system setup + +import os +import sys + +# Init +os.chdir(os.path.dirname(os.path.realpath(__file__))) +sys.path.append(os.getcwd()) +from functions.activation import * +from functions.browsers import * +from functions.cleanup import * +from functions.info import * +from functions.product_keys import * +from functions.setup import * +from functions.sw_diags import * +init_global_vars() +os.system('title {}: New System Setup'.format(KIT_NAME_FULL)) +set_log_file('New System Setup.log') + +if __name__ == '__main__': + other_results = { + 'Error': { + 'BIOSKeyNotFoundError': 'BIOS key not found', + 'CalledProcessError': 'Unknown Error', + 'FileNotFoundError': 'File not found', + 'GenericError': 'Unknown Error', + 'SecureBootDisabledError': 'Disabled', + }, + 'Warning': { + 'GenericRepair': 'Repaired', + 'NoProfilesError': 'No profiles found', + 'NotInstalledError': 'Not installed', + 'OSInstalledLegacyError': 'OS installed Legacy', + 'SecureBootNotAvailError': 'Not available', + 'SecureBootUnknownError': 'Unknown', + 'UnsupportedOSError': 'Unsupported OS', + }} + try: + stay_awake() + clear_screen() + + # Check installed OS + os_needs_updated = check_for_outdated_os(show_alert=True) + if os_needs_updated: + print_warning('OS version not supported by this script') + if not ask('Continue anyway? (NOT RECOMMENDED)'): + abort() + + # Scan for supported browsers + print_info('Scanning for browsers') + scan_for_browsers() + + # Select AV software + # NOTE: Truth tuple is (ESET, ESET_PUPS, MSE) + av_options = [ + {'Name': 'ESET NOD32', + 'Truths': (True, True, False),}, + {'Name': 'ESET NOD32 (no PUP/PUW scans)', + 'Truths': (True, False, False),}, + {'Name': 'Microsoft Security Essentials', + 'Disabled': global_vars['OS']['Version'] not in ['7'], + 'Truths': (False, False, True),}, + ] + actions = [ + {'Name': 'None', 'Letter': 'N'}, + {'Name': 'Quit', 'Letter': 'Q'}, + ] + selection = menu_select( + 'Please select an option to install', + main_entries=av_options, + action_entries=actions) + if selection.isnumeric(): + index = int(selection) - 1 + answer_eset, answer_pups, answer_mse = av_options[index]['Truths'] + elif selection == 'Q': + abort() + else: + answer_eset = False + answer_pups = False + answer_mse = False + + # Install LibreOffice? + answer_libreoffice = ask('Install LibreOffice?') + + # Install software + print_info('Installing Programs') + install_vcredists() + if answer_eset: + install_eset_nod32_av(scan_pups=answer_pups) + result = try_and_print( + message='Ninite bundle...', + function=install_ninite_bundle, cs='Started', + mse=answer_mse, libreoffice=answer_libreoffice, + other_results=other_results) + for proc in result['Out']: + # Wait for all processes to finish + proc.wait() + + # Install extensions + print_info('Installing Extensions') + try_and_print(message='Classic Shell skin...', + function=install_classicstart_skin, + other_results=other_results) + try_and_print(message='Google Chrome extensions...', + function=install_chrome_extensions) + try_and_print(message='Mozilla Firefox extensions...', + function=install_firefox_extensions, + other_results=other_results) + + # Configure software + print_info('Configuring programs') + install_adblock() + if global_vars['OS']['Version'] == '10': + try_and_print(message='ClassicStart...', + function=config_classicstart, cs='Done') + try_and_print(message='Explorer...', + function=config_explorer_user, cs='Done') + + # Configure system + print_info('Configuring system') + if global_vars['OS']['Version'] == '10': + try_and_print(message='Explorer...', + function=config_explorer_system, cs='Done') + try_and_print(message='Disabling telemetry...', + function=disable_windows_telemetry, cs='Done') + try_and_print(message='Enabling RegBack...', + function=enable_regback, cs='Done') + try_and_print(message='Enabling System Restore...', + function=enable_system_restore, cs='Done') + try_and_print(message='Updating Clock...', + function=update_clock, cs='Done') + + # 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) + if (not windows_is_activated() + and global_vars['OS']['Version'] in ('8', '8.1', '10')): + try_and_print(message='BIOS Activation:', + function=activate_with_bios, + other_results=other_results) + try_and_print(message='Secure Boot Status:', + function=check_secure_boot_status, other_results=other_results) + try_and_print(message='Installed RAM:', + function=show_installed_ram, ns='Unknown', silent_function=False) + show_free_space() + try_and_print(message='Installed Antivirus:', + function=get_installed_antivirus, ns='Unknown', + other_results=other_results, print_return=True) + + # Play audio, show devices, open Windows updates, and open Activation + try_and_print(message='Opening Device Manager...', + function=open_device_manager, cs='Started') + try_and_print(message='Opening HWiNFO (Sensors)...', + function=run_hwinfo_sensors, cs='Started', other_results=other_results) + try_and_print(message='Opening Windows Updates...', + function=open_windows_updates, cs='Started') + if not windows_is_activated(): + try_and_print(message='Opening Windows Activation...', + function=open_windows_activation, cs='Started') + sleep(3) + try_and_print(message='Running XMPlay...', + function=run_xmplay, cs='Started', other_results=other_results) + try: + check_secure_boot_status(show_alert=True) + except: + # Only trying to open alert message boxes + pass + + # Done + print_standard('\nDone.') + pause('Press Enter to exit...') + exit_script() + except SystemExit: + pass + except: + major_exception() + +# vim: sts=2 sw=2 ts=2 diff --git a/.bin/Scripts/settings/launchers.py b/.bin/Scripts/settings/launchers.py index 9679184e..a1f29683 100644 --- a/.bin/Scripts/settings/launchers.py +++ b/.bin/Scripts/settings/launchers.py @@ -13,6 +13,12 @@ LAUNCHERS = { 'L_PATH': 'd7II', 'L_ITEM': 'd7II.exe', }, + 'New System Setup': { + 'L_TYPE': 'PyScript', + 'L_PATH': 'Scripts', + 'L_ITEM': 'new_system_setup.py', + 'L_ELEV': 'True', + }, 'Post-d7II Work': { 'L_TYPE': 'PyScript', 'L_PATH': 'Scripts',