Zend certified PHP/Magento developer

What’s MS way to replace the Windows System and keep user directory from WinPE?

I’m messing around with two full-partition installations of Windows 11 & 10 on two separate drives using the BIOS F12 startup-drive-selector to change disks and windows installs. (Windows system selector and BCDEDIT didn’t work out for me). Win11 is the default boot drive. Not using the Win10 drive too much, I had a lot of updates to do. One of these Win10-restart-updates booted into the default Win11 system. Now the Win11 system will not boot. All the files and apps are fine. It’s just the system that’s borked.

I tried the simple things:

  • Startup Repair: Results: “couldn’t repair your PC.”
  • Reset this PC, Keep my files; Remove apps and settings. Results: “There was a problem resetting your PC. No changes were made”
  • Uninstall updates (both), “We ran into a problem and won’t be able to uninstall”

I tried some things at the CMD prompt in the WinPE environment, but (nearly) every option has a roadblock:

  1. BCDEDIT, shows only Win11 boot entry (expected) and it’s pointing to the correct drive letter. GOOD.

  2. I can navigate to both Win11 and Win10 disks and see all the files. The drives are healthy. GOOD.

  3. CHKDSK reports “no problems”. GOOD.

  4. SFC fails with error: “Windows resource protection could not perform the requested operation” (see note below)

sfc /scannow /offbootdir={winpe} /offwindir={win11}Windows

A blog post suggests this error is due to one of three issues: TrustedInstaller service is disabled, supporting DLL files are missing, file system corruption on the system drive (use DISM). The first issue’s resolution suggests using a command sc which is not available in WinPE, but the TrustedInstaller service can be started. There are no DLL file issues reported in the log file. That leaves the last question about the file system, let’s try DISM.

  1. DISM, Error: “Cleanup-image option is unknown”

dism /Online /Cleanup-Image /CheckHealth

Further investigation suggests the /Online option doesn’t make sense from the WinPE environment. You should use /source

  1. Mount a source image file:

`dism /mount-wim /wimfile:WIM:X:SourcesInstall.wim /index:1 /mountdir:x:Mount

  • created mount directory, x:mount
  • Used DISKPART to get drive letter for Win11 Install USB, g:, and clean WIN source image file.
  • DISM Error: “cannot find the path specified”. If I remove the WIM from: /wimfile:WIM:{drive}sourcesinstall.wim then I get a new error (What’s this syntax supposed to do for me?)
  • Trying to troubleshoot the error, I checked the Microsoft page on DISM and could not find the /mount-wim parameter. I read further to find /mount-image. Seems the latter is the new way

dism /mount-image /imagefile:g:sourcesinstall.wim /index:6 /mountdir:x:mount

  • Get error: “Error: 5; Access is denied.” Not sure what this refers to. There is no disk encryption. And I can fully access files in both Win10 and Win11 disks. I even copied files from the borked Win11 to Win10 in anticipation of a simple reinstall of the full system.

At this point I’m wondering, What’s MS way to replace the Windows System and keep user files while in the WinPE environment?


Note: Lots of examples of the SFC and DISM commands seem to not consider the WinPE environment context. For example, some command examples use same drive letter for both options, but that doesn’t seem to apply to WinPE; see step 5 of Repair Windows 11 with offline SFC scan at boot