How to Repair Windows System Files With SFC and DISM

Cream first-aid pouch with a red zipper and rolled bandages on a white table, a general picture for repairing Windows system files

If Windows crashes, apps fail with strange errors or updates will not install, damaged system files may be the cause. Windows has two built-in repair tools for this, SFC and DISM. This guide explains what each does, the correct order, what a good result looks like and what to do when a tool fails.

What the tools do

  • DISM (Deployment Image Servicing and Management) repairs the Windows component store, which holds good copies of system files.
  • SFC (System File Checker) checks your system files and replaces damaged ones using the component store.

If the store itself is damaged, SFC cannot repair files, so DISM comes first. Microsoft describes both tools in its pages on Use the System File Checker tool to repair missing or corrupted system files and on DISM image repair. Neither tool fixes registry problems, so read why registry cleaners are not a repair tool before you run one. If you are weighing DISM against a registry cleaner, compare them in registry cleaners versus DISM repair.

When to use them

Step-by-step: run DISM and SFC

Step 1: Open an administrator Command Prompt

Search for Command Prompt (or Terminal), right-click it and choose Run as administrator. Confirm the window title says Administrator. Without it both tools stop with Error: 5 Access is denied or You must be an administrator. If Windows says a command is not recognized, see our guide to fixing PATH and environment variables. Keep the PC plugged in and connected to the internet.

Step 2: Check and repair the component store with DISM

Run these commands in order:

DISM /Online /Cleanup-Image /CheckHealth
DISM /Online /Cleanup-Image /ScanHealth
DISM /Online /Cleanup-Image /RestoreHealth
  • CheckHealth takes a few seconds. It says No component store corruption detected or The component store is repairable.
  • ScanHealth scans in more detail and can take several minutes.
  • RestoreHealth repairs the store. The percentage can stay at 20 or 62 for a long time. Do not close the window.

You should see: The restore operation completed successfully. at the end of RestoreHealth. If CheckHealth reports no corruption, you can still run RestoreHealth, but it is not needed.

If DISM shows an error:

  • 0x800f081f or "The source files could not be found": DISM could not download good files from Windows Update. Check the internet connection and try again. If it still fails, use a Windows ISO as the source (see below). Our guide to DISM error 0x800f081f explains this case in full.
  • 0x800f0906 or 0x800f0907: the same problem. A network policy or a missing update source blocked the download.
  • Error 87: the command has a typo. Check the spaces before each slash.

Use a Windows ISO as the source: download a Windows 11 ISO from Microsoft, right-click it and choose Mount. Note the new drive letter (for example E:). In the mounted drive open the sources folder and see whether the file is called install.wim or install.esd. An ISO holds several editions, each with an index number, and the number must match the edition installed on your PC (shown by Settings > System > About). List them with:

DISM /Get-WimInfo /WimFile:E:\sources\install.wim

Find the line Name that matches your edition (for example Windows 11 Home or Windows 11 Pro) and note its Index. Then run the repair with that number in place of 1:

DISM /Online /Cleanup-Image /RestoreHealth /Source:WIM:E:\sources\install.wim:1 /LimitAccess

Use ESD: instead of WIM: and install.esd if that is the file you have. Replace E: with your drive letter. The ISO must match your Windows edition and language, or the repair will fail.

Step 3: Run SFC

When DISM finishes, run:

sfc /scannow

Wait for the verification to reach 100 percent. This can take a long time. Do not close the window.

Step 4: Read the result

  • "Windows Resource Protection did not find any integrity violations": no system file problems. If the original problem remains, the cause is elsewhere, for example a driver or a program.
  • "Windows Resource Protection found corrupt files and successfully repaired them": restart the PC and run sfc /scannow once more. The second run should say it found no violations.
  • "Windows Resource Protection found corrupt files but was unable to fix some of them": go to Step 5.
  • "Windows Resource Protection could not perform the requested operation": run SFC in Safe Mode (Step 5, point 2).

Step 5: If SFC cannot repair some files

  1. Run DISM /RestoreHealth again (with the ISO source if needed), restart, and run SFC again. SFC can only repair what DISM has first restored.
  2. Run SFC in Safe Mode, which stops other programs from locking files.
  3. To see which files could not be repaired, run this command. It saves the SFC entries from the log to your desktop:
findstr /c:"[SR]" %windir%\Logs\CBS\CBS.log > "%userprofile%\Desktop\sfclogs.txt"

Open sfclogs.txt and search for Cannot repair member file. The file names there tell you which parts are damaged. A search for those names often shows whether one app or one Windows feature is affected. Runtime files need their own steps: see our guide if the missing file is MSVCP140.dll or VCRUNTIME140.dll. If SFC reports errors it cannot fix on registry entries or keys with access denied, see how to fix registry permission errors in Windows. For how SFC differs from a registry cleaner, see SFC against registry cleaners.

Step 6: If Windows will not start

Start from a recovery drive or installation media (see how to create a Windows 11 recovery drive), choose Repair your computer > Troubleshoot > Advanced options > Command Prompt and run an offline scan. In the recovery environment the Windows drive may not be C:. Find the right letter first: type dir C:\Windows, then try D: and E: until it lists the Windows folder. Then use that letter in the command:

sfc /scannow /offbootdir=C:\ /offwindir=C:\Windows

If this reports files it cannot repair, run DISM offline as well, with a scratch folder on the same drive:

mkdir C:\scratch
DISM /Image:C:\ /ScratchDir:C:\scratch /Cleanup-Image /RestoreHealth /Source:WIM:E:\sources\install.wim:1

Here C: is the Windows drive and E: is the drive that holds your installation media. Check both letters first, and use the edition index from DISM /Get-WimInfo as above.

Step 7: The last options

If the tools keep failing, a repair install that keeps your files and apps, or resetting Windows, usually solves it. Back up your files first (see how to back up your Windows PC). If SFC keeps finding new damage after each repair, a failing drive may be the cause. Check it with how to check drive health.

More help

For other crashes and errors, search by symptom in the PC repair guides on PC Repair Atlas.

FAQ

Is it safe to run SFC and DISM? Yes. They only replace damaged system files with good copies.

Why does DISM seem stuck? It can pause at certain percentages, often 20 or 62. Give it up to 30 minutes, and check that the drive light or activity is still moving.

Do they fix malware? No. Scan for malware too. See remove a virus or malware.