-
Notifications
You must be signed in to change notification settings - Fork 0
Scripts Windows SafeMode
Scripts in Scripts/Windows/SafeMode/. Both require administrator privileges.
Safe Mode with Networking loads a minimal driver set plus network drivers. It is useful for:
- Malware removal (malware often cannot run without its normal startup context)
- Driver troubleshooting (a bad driver causing a blue screen won't load in Safe Mode)
- Remote diagnostics (network is available unlike plain Safe Mode)
What it does: Sets the bcdedit safeboot flag to network and immediately reboots the machine into Safe Mode with Networking.
Parameters: None.
Requirements: Administrator privileges. Will reboot immediately.
Usage:
.\Scripts\Windows\SafeMode\Enter-SafeMode.ps1How it works:
bcdedit.exe /set '{current}' safeboot network
Restart-Computer -ForceImportant: Save all work before running this. The reboot is immediate and forced — there is no confirmation prompt.
To undo before rebooting: If you set this flag by mistake and haven't rebooted yet, run Exit-SafeMode.ps1 to clear it before the restart.
What it does: Removes the bcdedit safeboot flag so the machine boots normally on the next restart. Does not reboot.
Parameters: None.
Requirements: Administrator privileges.
Usage:
.\Scripts\Windows\SafeMode\Exit-SafeMode.ps1How it works:
bcdedit /deletevalue '{current}' safebootRun this while in Safe Mode, then restart manually when ready. Or run it before a scheduled reboot if you accidentally set the Safe Mode flag.
# Step 1: Enter Safe Mode (reboots immediately)
.\Scripts\Windows\SafeMode\Enter-SafeMode.ps1
# --- machine reboots into Safe Mode ---
# Step 2: Do your troubleshooting work
# Step 3: Clear the flag while still in Safe Mode
.\Scripts\Windows\SafeMode\Exit-SafeMode.ps1
# Step 4: Restart to return to normal boot
Restart-Computer"This script needs to be run as an administrator." Right-click your PowerShell shortcut → "Run as administrator", then run the script.
bcdedit fails with "Access denied" You are not running as administrator. The script checks and exits rather than auto-elevating. See above.
Machine stuck in Safe Mode after Enter-SafeMode.ps1
If the machine always reboots into Safe Mode, boot into Safe Mode and run Exit-SafeMode.ps1, then reboot normally.
If you cannot boot at all, use Windows Recovery Environment (WinRE):
- Boot from Windows installation media.
- Choose "Repair your computer" → Troubleshoot → Advanced options → Command Prompt.
- Run:
bcdedit /deletevalue {default} safeboot - Restart.