Software & OS

SFC /scannow and DISM: How to Repair Windows System Files

Open Command Prompt as administrator and run DISM /Online /Cleanup-Image /RestoreHealth, then sfc /scannow. DISM repairs the component store that Windows keeps its spare copies in, and SFC then uses that store to replace any damaged or missing protected system files.

This is the order Microsoft's own support article uses. Both commands need an elevated prompt, both can take several minutes, and neither touches your personal files.

How to run sfc /scannow

  1. Press Start, type cmd, right-click Command Prompt and choose Run as administrator. Windows Terminal (Admin) works too.
  2. Run the DISM repair first:
    DISM /Online /Cleanup-Image /RestoreHealth
  3. When DISM finishes, run System File Checker:
    sfc /scannow
  4. Leave the window open until the verification reaches 100%, then read the result message (the table below explains each one).

If you skip the elevation step, neither tool runs. These are the exact messages from a non-administrator prompt on Windows 11:

You must be an administrator running a console session in order to use the sfc utility.
Error: 740

Elevated permissions are required to run DISM.
Use an elevated command prompt to complete these tasks.

What the SFC result messages mean

SFC ends with one of four messages:

MessageWhat it meansWhat to do
Windows Resource Protection did not find any integrity violations.No missing or corrupted protected files.Nothing. Your problem is somewhere else.
Windows Resource Protection found corrupt files and successfully repaired them.Damaged files were replaced.Restart, then check whether the original problem is gone. Details are in CBS.log.
Windows Resource Protection found corrupt files but was unable to fix some of them.Some files could not be replaced from the component store.Run DISM /RestoreHealth (again, or with a /Source), then SFC again. If it still fails, replace the named files by hand (see below).
Windows Resource Protection could not perform the requested operation.SFC could not run the scan.Run it again in Safe Mode, and check that the PendingDeletes and PendingRenames folders exist under %WinDir%\WinSxS\Temp.

What DISM CheckHealth, ScanHealth and RestoreHealth do

All three are switches of DISM /Online /Cleanup-Image. /Online means "the Windows installation I'm running now" rather than an offline image file.

CommandWhat it doesRepairs anything?
DISM /Online /Cleanup-Image /CheckHealthChecks whether the image has already been flagged as corrupted by a failed process, and whether that corruption can be repaired. Reports healthy, repairable or non-repairable.No
DISM /Online /Cleanup-Image /ScanHealthScans the image for component store corruption. Takes several minutes.No
DISM /Online /Cleanup-Image /RestoreHealthScans for component store corruption, then repairs it automatically. Takes several minutes.Yes

CheckHealth is quick because it only reads a flag that an earlier failure left behind. ScanHealth does the full scan without changing anything. In practice most people go straight to RestoreHealth, which scans and repairs in one pass.

DISM RestoreHealth without Windows Update: /Source and /LimitAccess

RestoreHealth needs known good copies of the damaged files. Unless you say otherwise, it uses the repair source configured by Group Policy and, on a running system, Windows Update. When Windows Update is the thing that's broken, give DISM another source and stop it from contacting Windows Update:

DISM /Online /Cleanup-Image /RestoreHealth /Source:C:\RepairSource\Windows /LimitAccess

C:\RepairSource\Windows is a placeholder. Microsoft lists suitable sources as the Windows folder of a mounted image, a running Windows installation, or a Windows side-by-side folder on a network share or removable media such as installation media. If you give several /Source arguments, DISM uses the first location where it finds each file and ignores the rest.

Where to find SFC's details: CBS.log

SFC writes its results into the Component-Based Servicing log at %windir%\Logs\CBS\CBS.log. That file also records other servicing activity, so extract just the SFC lines (they are tagged [SR]) into a file on your desktop:

findstr /c:"[SR]" %windir%\Logs\CBS\CBS.log >"%userprofile%\Desktop\sfcdetails.txt"

Run it from the same elevated Command Prompt. The output contains entries from every SFC run on the PC, so use the timestamps to find your latest scan. Files SFC could not fix are marked with Cannot repair member file. DISM keeps its own log at %windir%\Logs\DISM\dism.log.

Fixing a file SFC can't repair

When the log names a file that SFC could not repair, you can replace it with a good copy taken from another PC running the same Windows version (ideally one that passes an SFC scan). Microsoft's procedure, from an elevated prompt:

takeown /f C:\Windows\System32\example.dll
icacls C:\Windows\System32\example.dll /grant administrators:F
copy D:\good-copy\example.dll C:\Windows\System32\example.dll

takeown gives administrators ownership of the file, icacls ... /grant administrators:F grants full control, and copy overwrites the damaged version. Replace example.dll with the exact path from the log. If several files are affected, or the copy fails, Microsoft's fallback is to reinstall or reset Windows.

Other useful sfc switches

SwitchUse it to
sfc /verifyonlyScan all protected files without repairing anything.
sfc /scanfile=C:\Windows\System32\kernel32.dllScan and repair one file (full path required).
sfc /verifyfile=C:\Windows\System32\kernel32.dllCheck one file without repairing it.
/offbootdir and /offwindirRepair a Windows installation that isn't running, for example from the recovery environment.

Running SFC when Windows won't boot

If Windows won't start, open Command Prompt from the Windows Recovery Environment or installation media and point SFC at the offline installation. Drive letters often change there, so check which letter holds the Windows folder first (dir D:\, dir E:\). Microsoft's example for an installation on D: is:

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

The same idea works for DISM with /Image: instead of /Online, for example DISM /Image:D:\ /Cleanup-Image /RestoreHealth /Source:.... An offline image can't use Windows Update, so it needs a /Source.

If it still fails

A clean SFC result means protected system files are fine, so look elsewhere: drivers, third-party software, or the disk itself. A failing drive keeps corrupting files no matter how often you repair them, so check the drive's health before running SFC for the third time. If Windows Update is what's broken, the update-specific steps in Windows Update stuck go further than SFC and DISM alone.

Frequently asked questions

Should I run DISM or SFC first?
Microsoft's support article runs DISM first, then SFC. SFC repairs protected system files from the local component store, and DISM /RestoreHealth repairs that component store. If the store itself is damaged, SFC has nothing good to copy from, so fixing the store first gives SFC the best chance.
Does sfc /scannow delete my files or apps?
No. SFC only checks protected Windows system files and replaces incorrect versions with correct ones. It does not touch your documents, photos or installed third-party programs.
Can I run sfc /scannow without administrator rights?
No. Without elevation, sfc prints 'You must be an administrator running a console session in order to use the sfc utility.' Open Command Prompt or Terminal with Run as administrator and run it again.
Does DISM need an internet connection?
By default, DISM /Online /Cleanup-Image /RestoreHealth can use Windows Update as a repair source. If Windows Update is broken or you are offline, point it at known good files with /Source and add /LimitAccess so it doesn't try Windows Update.
Is it safe to stop sfc /scannow halfway?
Microsoft's instructions say to keep the Command Prompt window open until the verification is 100% complete. If you interrupt it, run the scan again from the start rather than assuming the earlier part was enough.

Sources