Skip to content

Instantly share code, notes, and snippets.

@drodsou
Last active May 29, 2025 20:24
Show Gist options
  • Save drodsou/867d5bc326ad44fcf7046babe73dd5fd to your computer and use it in GitHub Desktop.
Save drodsou/867d5bc326ad44fcf7046babe73dd5fd to your computer and use it in GitHub Desktop.
Windows boot related commands

WINDOWS 10 BOOT TROUBLESHOOTING 😥

NO-HOPE WARNING: There is a HUGE probability that none of these things or the recovery options will bring back your Windows 10 to life. Also become aware that you CAN'T "reinstall preserving your data" from the installation DVD if your PC doesn't boot already. Great for you Microsoft...

Tips

  • Windows 10 has its small boot partition (which must be the "active" one -see diskpart or diskmgmt.msc- with a \boot\bcd file where the boot options of bcdedit are stored

  • Booting from installation DVD / recover usually c: and d: are swapped from normal boots (being c: the boot partition and d: where windows\system is, so don't freak out

  • Make a restauration point before doing something that can mess with the boot

bcdedit

Tip: Sysprep wipes your dear bcdedit config, so make sure to export/import before and after sysprep

► Great info

Specially step 3

https://neosmart.net/wiki/recovering-windows-bootloader/

► Basic usage

bcdedit
bcdedit /store d:\boot\bcd /enum all

► add entry

bcdedit /copy {default} /d "new entry"
bcdedit /set {NEWGUID} osdevice partition=E:
bcdedit /set {NEWGUID} device partition=E:

► classic boot partition selector

Also allows F8 to enter safe mode as in Windows 7

bcdedit /set {default} bootmenupolicy legacy

► disable auto-recovery on boot

Usefull to see exact error. Maybe c:\windows\system32 is REALLY missing (!)

bcdedit /set {default} recoveryenabled No

chkdsk /f

or /r for /f + recover bad sectors

sfc /scannow

On external drive

Related

  • CLFS.sys error (it's in windows\system32\drivers)
  • windows resource protection could not perform the requested operation => try to run from a parallel windows, with target unmounted

dism

Make sure you have permisions to open all folders (try the disk form a working win 10)

The great hope, the closest thing to a "reinstall without loosing data" from DVD (but which will probably fail at 97%...)

dism /Image:D:\ /cleanup-image /restorehealth /source:WIM:e:\sources\install.wim:1 /limitaccess /ScratchDir:d:\tmpDism
  • Tip: "Online" means "current" OS, not "over internet"

DISM.exe /Online /Cleanup-image /Checkhealth DISM.exe /Online /Cleanup-image /startcomponentcleanup DISM.exe /Online /Cleanup-image /Restorehealth

Powershell -ExecutionPolicy Unrestricted Add-AppxPackage -DisableDevelopmentMode -Register $Env:SystemRoot\WinStore\AppxManifest.XML

► DISM vs SFC

Note from: https://answers.microsoft.com/en-us/insider/forum/insider_wintp-insider_install/how-to-repair-your-system-files-using-dism-and-sfc/1021b42a-09ff-41a0-a95a-48f3ee3ae699

1. Mount the .ISO file by double clicking on it.
2. Open 'Windows Powershell' or 'Command Prompt' with Admin privileges (right click -> Run as Administrator)
3. Let's check the System Health first, by running these commands:
  3.1 dism /online /cleanup-image /scanhealth
  3.2 dism /online /cleanup-image /checkhealth
  3.3 dism /online /cleanup-image /restorehealth
4. I'm sure that 3.3 will give you an error stating that it could not perform the task. And now it's when the mounted ISO comes into play. Let's specify the file from the ISO so that we can fix it. Run the following command: (Notice that X must be the drive letter on which your system has mounted the ISO)
  4.1 DISM /Online /Cleanup-Image /RestoreHealth /source:WIM:X:\Sources\Install.wim:1 /LimitAccess
5. Now let's repair any damage in the system files, shall we?
  5.1 sfc /scannow

bootrec

*bootrec /scanos* : bad thing if it finds  :0 windows installations

bootrec /fixmbr
bootrec /fixboot
bootrec /rebuildbcd

► tough rebuildbcd

cd boot
attrib bcd -s -h -r
ren c:\boot\bcd bcd.old
bootrec /RebuildBcd

Regedit

The place where drive/letter association are stored.

Tip: sysprep resets it, so be sure to export / import it before and after doing an OOBE

HKLM\SYSTEM\MountedDevices

diskmgmt.msc

easybcd

msconfig: safeboot

To reboot in safe mode in Windows 10

msconfig / boot tab / safe boot / ok

robocopy

Standard Win7+ command. When everything fails, to efficiently copy (update) files, and avoiding "FILE TOO LONG" crap of File Explorer

robocopy d:\somedir c:\folder\somedir /E /R:0 /NFL /NDL > log.txt
  • /E recursive including empty folders
  • /R:0 no retires on error
  • /NFL and /NDL : dont log correctly copied files

when windows 10 believes it's hard drive is an usb

A message big blue modal message may appear "don't disconnect your usb drive...". It may happen if you cloned the OS from a USB

reg add HKLM\SYSTEM\CurrentControlSet\Control /v PortableOperatingSystem /t REG_DWORD /d 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment