[Tip for Win10] How to detect and repair corrupted system files

@ all Win10 users:

According to my own experience it happens very often, that a fresh Win10 installation completes fine, but nevertheless some of the stored original MS system files have got corrupted during the installation process. Such broken or invalid system files may cause later on severe problems during the daily work with the OS and the search for the origin may be very difficult and time consuming.

That is why I recommend to do the following steps after each fresh Win10 installation:

A. Execute the Win10 in-box "System File Check"

  1. Run the Command Prompt as Admin and enter the following command (without quotation marks):
    "sfc /scannow"
  2. Hit the “Enter” key.
  3. After the System File Check has been completed, you will get a message about the result.
    There are at least 3 possible messages:
    • a) No corrupted system files were found.
      Consequence for you: Everything is fine and you can start working with Win10 without worrying about corrupted OS system files.
    
    
  4. b) Corrupted files were found, but could be automaticly repaired
    This is the exact message you may get (in your language):

    SFC Reparation Report.png


    Consequence for you: Due to the reparation work of the SFC tool everything seems to be fine for you now.
    If you want absolutely security, you can re-run the above SFC command. The tool should not find any corrupted system files anymore.

  5. 
    
  6. c) Corrupted files were found, but could not be repaired.
    The worst case is the following message:

    SFC Errors.png


    Consequence for you: There is a need for additional work (see below), but not for a repetition of the OS installation.



B. Execute the DISM “Cleanup-Image” Command

Furtunately Win10 has the required instruments “on board” for a reparation of the corrupted system files.
Required: The Win10 installation media, where you booted from to get the OS installed. It has to contain an install.wim file within the folder “sources” (if there is just a file named install.esd, you may have to decrypt it by using an ESD Decrypter tool).
This is what you have to do:
  1. Insert the Win10 installation media (USB/DVD) and check the drive letter of it.
  2. Run the Command Prompt as Admin and enter the following command (without quotation marks):
    "dism /online /cleanup-image /restorehealth /source:wim:X:\sources\install.wim:1 /limitaccess"
    Notes:
    • The letter “X” has to be replaced by the drive letter of your currently inserted Win10 installation media.
    • Maybe the INSTALL.WIM number (here: “1”) has to be replaced by the number of the image you had chosen to get installed (if there are more than 1 image within the media).
  3. Hit the “Enter” key.
  4. After having completed the reparation procedure you will hopefully get the following message:

    
    
  5. Re-run the SFC tool (see above).
  6. If the tool should still find corrupted, but unrepairable system files, you may re-execute the DISM "Cieanup-Image" command.


Good luck!
Dieter (alias Fernando)
1 Like

@Fernando ,

After the recent W10 x64 Update (Build 14393.576) I think have some understandable problems such as close Firefox which is already close, etc…
So, I have tried to detect and repair corrupted system files according to your Guidelines.
1) typo: a missing " → "X:"
2) here is screenshot I got:

RESTORE_HEALTH_failure.PNG



As you can see I get an error.

However, my W10 x64 install USB key (I:) freshly downloaded is:

ESD_USB_TreeSize_W10x64v1607.PNG



I don’t see was is wrong.

DISM log file (extract):

DISM_log.PNG



Do you see where is the problem to get a functional "RESTOREHEALTH" ?

@100PIER :
You should use an USB Flash Drive containing a "normal" OS image with an INSTALL.WIM as source.
If your current OS image just contains an INSTALL.ESD file, you can easily create a full ISO file incl. install.wim by using an ESD-Decrypter.
This is how the content of the bootable USB Flash Drive should look:

Install-wim.png

@Fernando ,
Many many thanks.
I have to use the excellent NTLite tool to convert ESD file to WIM file, and have a look on what Install.WIM number value to use. (in my case it is value 2).

W10_USB_NTLite.PNG



The RESTOREHEALTH option worked fine:

RESTORE_HEALTH_OK.PNG



You should update Post #1:
Point 2 Command Prompt to replace "X: with "X":
and also modify
Notes:, item 3, that you have first to convert INSTALL.ESD file to INSTALL.WIM file using a ESD-Decrypter Tool such as NTLite Tool.

You are wrong regarding this point. The complete path to the install.wim has to be set within quotation marks.
Look here:


Done!
By the way: The tool NTLite is able to convert an install.esd to an install.wim, but if you are not using NTLite anyway, it is much easier to use a special ESD Decrypter.

@Fernando ,
If you are looking my screenshot the complete path without any quotation marks does work fine as well.
What special ESD Decrypter Tool do you use ?

You are right - the quotation marks within the command are obviously not really required. So I have removed them within the start post.

Currently I am using the ESD Decrypter wimlib v26 created by Adguard (MDL). The tool is attached.
How to use it:
1. Unzip the package into a special folder.
2. Copy or move the install.esd file you want to get decrypted into the folder.
3. Right-click onto the file named decrypt.cmd and choose the option "Run as Administrator".
4. Choose the option "1", if you want to get an ISO file, which contains an install.wim file.
5. The rest will be done automaticly.

esd-decrypter-wimlib-26.rar (2.48 MB)

@Fernando ,
Thanks for the ESD Decrypter Tools.

You said:
If your Win10 installation image contains an INSTALL.ESD instead of an INSTALL.WIM, you should replace "install.wim" by "install.esd".
I had tried this to refer to "install.esd" in the command line. I got an error.
I think you have to convert first the "install.ESD" file to "install.WIM" and then entering the command line using the "install.WIM".
For "install.ESD" conversion to "install.WIM" you have the choice between specific ESD Decrypter Tool such as WIMLIB v26 or a generic Tool such as NTLite.

@100PIER :
Thanks for your statement. You are right. To avoid any misunderstandings, I have removed the related line from the “Notes” within the start post.
The fact, that the DISM “Cleanup-Image” command doesn’t work, if there is an install.esd present instead of an install.wim, should be clear enough by reading the second sentence within the chapter “Required:”.

@Fernando ,
Thanks, all is quite clear.

Hi,
Right now I can not boot to Windows 10 on my daughter’s laptop (Medion Akoya E7214/MD98410) because during the process of moving system partition it was rebooted and now is stuck on the BSOD with CRITICAL PROCESS DIED message (and kept rebooting until I tweaked AutoReboot flag in the Registry). I was unable to find out what is causing CRITICAL PROCESS DIED message and assume that there is a problem with potentially corrupted system files and need to check/restore them. Additionally, I need to boot system in the Safe Mode. Thus, there are two questions:

1. I can boot from USB/DVD-ROM with either miniXP or miniWin7 (i.e. Mini 7 is on X: drive and targeted Win 10 system is on D: drive) but when I run

sfc /scannow

(after initiating TrustedInstaller service) it starts working, gradually runs upto 100% without reporting any errors but at the end it is producing a message

Windows Resource Protection could not perform the requested Service?

Does it mean that I may assume that system files on D: drive are OK? Or there must be some other outcome to be 100% sure?

2. Win10 was installed by upgrade via download to Win7 and there is no installation media (and there is no any backup or Repair Drive). Alternative installation media which I have contains different version of Win10 and can not repair laptop version. I assume that booting in Safe Mode may help to cure the problem. All recommendations which I was able to find about forcing to start in the Safe Mode are assuming a case of making preparations from within healthy Win10 (e.g. msconfig) which is not a case. I can edit Registry or other config files of the target D: drive with Win10 but need to know what exactly has to be done in order to force Win10 to boot in Safe Mode (and no - F8/Shift-F8/Shift-Reboot does not work either).

Please advise. Re-installing Win10 is not an option because on the laptop are installed important software packages.

What if some files where updated by Windows Update? There’s still no 10.0.16299.309 ISO…

@gpvecchi :
Haven’t tried it yet, but I think, that the tool will detect, whether the related system files belong to the original OS or have been updated later.

Many thanks, if someone is interested, this is the command for online files download, without the need for Windows support disk/USB.

DISM /Online /Cleanup-Image /RestoreHealth

This worked for me

I use with online windows. You can check file for repaired or not repaired files.
check_sfc_files.cmd

1
2
3
4
5
6
7
8
 

sfc /scannow
findstr /c:"[SR]" %windir%\Logs\CBS\CBS.log >"C:\sfc.txt"
C:\sfc.txt
pause
del C:\sfc.txt
exit
 
 


Offline windows
check_sfc_files_offline.cmd
1
2
3
4
5
6
 

sfc /scannow /OFFBOOTDIR=c:\ /OFFWINDIR=c:\windows /OFFLOGFILE=%windir%\Logs\CBS\CBS.txt
findstr /c:"[SR]" %windir%\Logs\CBS\CBS.txt >"%userprofile%\Desktop\sfc.txt"
"%userprofile%\Desktop\sfc.txt"
 

 

hate to dig up an old thread but for future reference DISM actually contains a utility to convert an .esd to a .wim however an esd is a combined library file that has multiple versions of windows in it ie home, pro, education etc. so you must first select the wim you wish to extract rather then re write it myself i will reference this external tutorial (disclaimer i have no relation to the site linked) https://www.itechguides.com/convert-esd-to-wim/