WizardKit/.bin/Scripts/safemode_enter.py
Alan Mason 41d6cfc209 2017-08: Retroactive Updates
* Bugfixes
  * Windows 10 v1703 / Redstone 2 / Creator's Update now recognized (attempt #2)
2017-11-17 00:57:07 -07:00

31 lines
1 KiB
Python

# Wizard Kit: Enter SafeMode by editing the BCD
import os
import sys
# Init
os.chdir(os.path.dirname(os.path.realpath(__file__)))
os.system('title Wizard Kit: SafeMode Tool')
sys.path.append(os.getcwd())
from functions import *
if __name__ == '__main__':
try:
if ask('Enable booting to SafeMode (with Networking)?'):
# Edit BCD to set safeboot as default
run_program('bcdedit /set {default} safeboot network', check=False)
# Enable MSI access under safemode
run_program(r'reg add HKLM\SYSTEM\CurrentControlSet\Control\SafeBoot\Network\MSIServer /f', check=False)
run_program(r'reg add HKLM\SYSTEM\CurrentControlSet\Control\SafeBoot\Network\MSIServer /ve /t REG_SZ /d "Service" /f', check=False)
## Done ##
pause('Press Enter to reboot...')
run_program('shutdown -r -t 3', check=False)
# Done
exit_script()
except SystemExit:
pass
except:
major_exception()