How to Fix Corrupted Windows System Files with SFC and DISM

SFC and DISM in the order that actually works, why DISM must run first, how to repair without Windows Update, and how to read CBS.log when it says it failed.

fix windows system files sfc dism

SFC and DISM get recommended constantly, usually as “just run these two commands”, and often in the wrong order. Run them the wrong way round on a machine with a damaged component store and SFC will report problems it cannot fix, which tells you nothing useful.

Here’s what each one actually does, the order that works, and how to read the log when it says it couldn’t repair something.

Quick Facts

  • Run DISM first, then SFC. SFC repairs system files using the component store, so the store has to be healthy first.
  • sfc /scannow checks protected system files against known-good copies.
  • DISM /RestoreHealth repairs the component store itself, pulling replacements from Windows Update.
  • Both need an elevated prompt. Neither touches your personal files.
  • If DISM can’t reach Windows Update, point it at install media with /Source. This is the fix people miss.

What each command is for

SFCDISM
ChecksProtected system files on diskThe component store (WinSxS)
Repairs fromThe local component storeWindows Update, or media you specify
Typical runtime5-15 minutes10-30 minutes, sometimes longer
Run it whenFiles are corrupted or behaving oddlySFC can’t repair, or updates keep failing
Needs internetNoUsually yes, unless you supply a source

The relationship is the important bit: SFC’s replacement parts come from the component store. If that store is itself damaged, SFC has nothing good to copy from, which is exactly the situation where people run SFC repeatedly and wonder why nothing improves.

The order that works

Quick Steps

  1. Open Terminal or Command Prompt as administrator.
  2. Run DISM /Online /Cleanup-Image /ScanHealth to check whether the store is damaged. Read-only, no changes.
  3. If it reports corruption, run DISM /Online /Cleanup-Image /RestoreHealth.
  4. Now run sfc /scannow.
  5. Run sfc /scannow a second time. The first pass can fix things that let the second pass fix more.
  6. Reboot, then verify whatever was broken.
DISM /Online /Cleanup-Image /ScanHealth
DISM /Online /Cleanup-Image /RestoreHealth
sfc /scannow

There’s also /CheckHealth, which is faster but only reports flags already recorded. It doesn’t scan. /ScanHealth does the actual work of looking.

When DISM can’t reach Windows Update

On a machine behind a restrictive proxy, or one pointed at a WSUS server that lacks the files, RestoreHealth fails with error 0x800f081f. That doesn’t mean the machine is unrecoverable. It means DISM had nowhere to get replacements from.

Mount an ISO matching the installed build and point DISM at it:

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

/LimitAccess stops it trying Windows Update at all. The build of the media should match the installed build. An older ISO often won’t have the right file versions.

Reading the log when it says it failed

SFC writes to %windir%\Logs\CBS\CBS.log, which is enormous and mostly noise. Extract just the relevant lines:

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

Open that on your desktop and look for “Cannot repair member file”. The filename that follows is what actually failed, and searching for it usually identifies which component or driver package is damaged.

If SFC repeatedly cannot repair the same file after a successful DISM run, you’re into in-place upgrade territory. Running setup from mounted media and choosing to keep files and apps. That rebuilds system files without touching your data, and is far quicker than a rebuild.

Glossary

TermWhat it means
Component storeThe WinSxS folder holding the master copies of Windows system files.
CBS.logComponent-Based Servicing log, where SFC and DISM record what they did.
0x800f081fSource files could not be found. DISM had no working repair source.
In-place upgradeReinstalling Windows over itself, keeping files, apps and most settings.
/LimitAccessTells DISM not to contact Windows Update, using only the source you specify.

Frequently asked questions

Should I run SFC or DISM first?

DISM first. SFC repairs using files from the component store, so if the store is damaged SFC has nothing good to copy from. Running SFC first on a damaged store is why people see “unable to fix” repeatedly.

Will SFC or DISM delete my files?

No. Both work only on Windows system files and the component store. Your documents, photos and installed programs are untouched.

How long should DISM RestoreHealth take?

Ten to thirty minutes is normal. It commonly appears to freeze at 20% for several minutes. That’s expected, leave it alone.

What if DISM fails with 0x800f081f?

It couldn’t find repair files. Mount an ISO matching your installed build and use the /Source parameter with /LimitAccess.

What if both complete but the problem remains?

Then the fault probably isn’t corrupted system files. Check Reliability Monitor for what changed around the time it started, and consider a driver or third-party software as the cause.

🛠️

Gear We Recommend

Keeping recovery media and a spare drive to hand makes this kind of repair far less stressful.

Browse our Storage & Backup picks on Amazon

As an Amazon Associate, TechyGeeksHome earns from qualifying purchases

Disclosure: this post may contain affiliate links. If you buy through one of them, we may earn a small commission at no extra cost to you. We only recommend products we’ve tested or genuinely rate.


Discover more from TechyGeeksHome

Subscribe to get the latest posts sent to your email.

Andrew Armstrong

Andrew Armstrong is a UK-based IT professional with 26+ years of hands-on experience in Windows, Windows Server, SCCM/ConfigMgr, Active Directory, PowerShell, and enterprise infrastructure.

He founded TechyGeeksHome in 2010 and has published over 1,500 practical guides covering real-world IT problems and solutions. When not solving IT problems,

Andrew develops free Windows utilities including Ultimate Settings Panel, which has been downloaded over 850,000 times.

Leave a Reply

Your email address will not be published. Required fields are marked *