Site icon Winhelponline

How to Repair Windows 10/11 System Files Using DISM and SFC

If the system files in your Windows 10/11 computer become corrupt and the System File Checker (SFC /scannow) is unable to reinstate the critical system files, it’s due to corruption of the Component Store located in the C:\Windows\WinSxS directory. This directory contains the files needed for the SFC utility to restore missing or damaged system files. The Component store stores all the Windows system files grouped by components and as hard links.

If the System File Checker is unable to repair/restore certain system files, it shows the following error:

Windows Resource Protection found corrupt files but was unable to fix some of them. Details are included in the CBS.Log %WinDir%\Logs\CBS\CBS.log.

A corrupted component store causes this error. There is a console tool named DISM (Deployment Image Servicing and Management) which ships with Windows. DISM is used to fix Windows Component Store corruption, especially when the System File Checker doesn’t help.

The DISM tool writes the following log files which help us analyze the operation status and errors:

This post tells you how to fix Windows 10 or Windows 11 if some system files or the component store are damaged.

Repair Windows 10 or 11 Using DISM and SFC

To repair Windows 10/11 using DISM and SFC, use the following steps:

Step 1: Check for component store corruption

Open an elevated command prompt and type the following command, and press Enter:

Dism /Online /Cleanup-Image /CheckHealth

The /CheckHealth is used to check whether the image has been flagged as corrupted by a failed process and whether the corruption can be repaired. Note that this command doesn’t scan the files or fix anything; it only reports any corruptions marked already.

Instead, to do a thorough check, then run DISM with the /ScanHealth parameter, as mentioned below, to check the component store for corruption. It scans for all files and verifies the hash values.

Dism /Online /Cleanup-Image /ScanHealth

It takes a significantly more extended amount of time than the CheckHealth option, but using this switch may be doing a thorough test, and it also writes the results to the dism.log file.

Difference between CheckHealth and ScanHealth

The CheckHealth command-line argument, as said earlier, reports if there is any corruption if already marked in the registry. It doesn’t scan the files. This parameter also reports if the component store corruption can be repaired or not.

If the following registry value is set, then the tool will report that the component store is corrupted:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing

DWORD Value name: Unserviceable
Data: 0 or 1

DWORD Value name: Corrupt
Data: 0 or 1

If Unserviceable is set to 1, then running DISM with /checkhealth parameter would report The component store cannot be repaired.

If Corrupt is set to 1 and Unserviceable is set to 0, DISM checkhealth would report The component store is repairable.

The ScanHealth command-line, on the other hand, doesn’t rely on the previously marked data. It would rather scan each file in the WinSxS directory and sub-directories, verify their hashes. It then reports if the component store is corrupted or healthy.

If the ScanHealth command-line finds the component store is healthy, it removes the corrupt and unserviceable values in the registry automatically, thereby marking the component store as healthy. The operations are logged on to the file dism.log.

Note: The DISM CheckHealth command-line was completed in less than 10 seconds. Whereas the ScanHealth command-line took 13 minutes to complete on my computer.

Step 2: Repair the component store

If the checkhealth or scanhealth command-line reports of any corruption (and if it’s repairable), run the following command to repair the component store:

Dism /Online /Cleanup-Image /RestoreHealth

When you run this command, DISM uses Windows Update to provide the files required to fix corruption. The command scans for component store corruption and does the repair operations automatically, writing the operational results to cbs.log and dism.log files. This process takes a long time to complete.

DISM RestoreHealth command fails to complete?

In some cases, the RestoreHealth command-line fails to run due to an unserviceable or corrupt image error (e.g., if your Windows Update client is already broken on the computer, DISM can’t fetch the missing files via the WU channel). Here are a couple of error codes that you may encounter:

The component store is in an inconsistent state.
The component store has been corrupted.

Error: 0x800f081f
The source files could not be found.
Use the “Source” option to specify the location of the files that are required to restore the feature.

In those cases, you need to mention the WIM file as the source from which you can restore corrupted system files.

Follow the instructions in the article to run the RestoreHealth operation, mentioning the source location (slipstreamed Windows 10/11 disk). For more information, check out the article DISM Error 0x800f081f During RestoreHealth

You’d use this syntax in that case:

Dism /Online /Cleanup-Image /RestoreHealth /Source:wim:Full Path to install.wim file:<Index>

Replace the <Index> placeholder in the above command with the actual index number for the Edition (“Home”, “Pro,” etc.) contained in the WIM file.

For example:

Dism /Online /Cleanup-Image /RestoreHealth /Source:wim:D:\Sources\install.wim:1

You can list available editions and their indexes with the following command:

dism /get-wiminfo /wimfile:F:\sources\install.wim

(Replace the F:\sources\ portion with the actual path to your WIM file.)

Running DISM command on install.wim or install.esd

For more information, see the article Find the Windows version, build and edition from ISO or DVD

*Important*: Don’t use ESD!

If you have install.esd (instead of install.wim) in the Windows 10/11 setup disk, you must convert the ESD file into WIM for the above DISM command to work. In our tests, DISM was unable to use Install.esd as the source and the command ended up with the 0x800f081f error every time, regardless of the syntax (/source:wim:h:\sources\install.esd or /source:esd:h:\sources\install.esd) used.

The following command is absolutely useless. Don’t use it. It does nothing.

Dism /Online /Cleanup-Image /RestoreHealth /Source:esd:"E:\Sources\Install.esd":1 /limitaccess

After converting the ESD file to WIM, I ran DISM mentioning the Install.wim file as the source. It ran perfectly fine, and it restored the missing manifest files indeed!

Please keep this important point in mind when running DISM.

Step 3: Run the System File Checker

After you fix the component store corruption (if any) using the DISM tool, follow up with the System File Checker to restore the critical system files.

Run the following command from an elevated command prompt:

sfc /scannow

For more information, refer to Microsoft articles Use the System File Checker tool to repair missing or corrupted system files and How to analyze the log file entries that the Microsoft Windows Resource Checker (SFC.exe) program generates

I hope that helps repair the component store and restore the Windows 10/11 system files.

Exit mobile version