Sub topic 7
Repairing system files with sfc and DISM
This chapter assumes you can open an elevated Command Prompt and read command help with /?. It also assumes you know what chkdsk does. chkdsk checks the file system, while sfc and DISM check the Windows files stored on it.
What each tool repairs
System File Checker (sfc) compares protected Windows files with cached known-good copies. If it finds a damaged or replaced file, it restores the cached copy. The cache is the component store, which is a folder (C:\Windows\WinSxS) that holds the original versions of system components.
Deployment Image Servicing and Management (DISM) repairs the component store itself. sfc can only restore a file from the store. If the store is corrupt, sfc cannot fix the file. DISM gets clean source files from Windows Update, or from a source you give it, and repairs the store.
Running sfc
Both tools need an elevated Command Prompt. Without elevation, sfc reports that you must be an administrator.
sfc /scannow
sfc /verifyonly/scannow checks and repairs. /verifyonly checks and reports without changing anything. A scan can take several minutes. Do not close the window while it runs.
The three common results are:
| Message | Meaning | Next step |
|---|---|---|
| Did not find any integrity violations | System files are intact | Look for other causes |
| Found corrupt files and successfully repaired them | Problem fixed | Restart and retest |
| Found corrupt files but was unable to fix some of them | The component store may be damaged | Run DISM, then `sfc` again |
Details are written to C:\Windows\Logs\CBS\CBS.log.
Running DISM
DISM /Online /Cleanup-Image /CheckHealth
DISM /Online /Cleanup-Image /ScanHealth
DISM /Online /Cleanup-Image /RestoreHealth/Online means the running copy of Windows. The three options go from lightest to heaviest:
/CheckHealthonly reads a flag that says whether corruption was already detected. It is fast and does not scan./ScanHealthscans the component store for corruption but does not repair it./RestoreHealthscans and repairs, downloading replacement files from Windows Update by default.
/RestoreHealth needs network access in its default mode. It can also appear to pause for a long time near 20 percent or 62 percent. That is normal, so wait before assuming it has hung.
Common errors
- Running
sfcwithout elevation. Reopen Command Prompt as administrator. - Running
sfcagain and again after it reports unfixable files. Run DISM first, thensfc. - Running DISM on a PC with no internet and no alternate source. It fails because it cannot reach Windows Update.
- Stopping a scan with Ctrl+C or by powering off. Let it finish.
Exercise
A technician runs sfc /scannow and sees "Windows Resource Protection found corrupt files but was unable to fix some of them." What should the technician run next, and what should be run after that?
Show answer
Run DISM /Online /Cleanup-Image /RestoreHealth to repair the component store, then run sfc /scannow again. The first sfc run failed because the store it copies from was damaged.
Exercise
Which command checks system files and reports problems without repairing them?
Show answer
sfc /verifyonly.