Check and repair damaged system files with these DISM commands.
Your Windows installation depends on a collection of important system files to run applications, install updates and perform everyday computing tasks. If these files get damaged or go missing, your system may behave erratically. You may encounter system errors, features not working as expected, freezes or other unexpected behavior. Sometimes restarting your computer or running the usual troubleshooting steps aren't enough to restore damaged system files. For such cases, Windows provides a built-in repair utility called Deployment Image Servicing and Management (DISM).
DISM is a command line tool that can scan Windows system images for corrupt system files and attempt repairs. Particularly, there are three useful DISM commands that achieve this purpose: CheckHealth, ScanHealth and RestoreHealth. You can run DISM commands in either the command prompt or the PowerShell, but both CLIs require administrator privileges to make system-level changes. It's worth noting that DISM exclusively scans and repairs system files; your personal files remain untouched.
Three DISM commands that fix damaged Windows installation
All three DISM commands in question follow a specific syntax that begins with DISM /Online /Cleanup-Image. The parts following "DISM" in the syntax are called command-line options. The /Online CLI option specifies DISM to take action on the currently running Windows installation, while /Cleanup-Image performs recovery operations on the selected installation.
The first command is DISM /Online /Cleanup-Image /CheckHealth. It checks whether Windows has already flagged corrupt system files and whether the corruption is repairable. This is the first recommended step when investigating corrupt system files as it takes very little time to complete.
The next command is DISM /Online /Cleanup-Image /ScanHealth and it works slightly differently from the CheckHealth command. Unlike CheckHealth, the ScanHealth DISM command performs a fresh scan of your system files and reports any its findings. The ScanHealth operation may take several minutes to complete, but it provides you with a fresh report on the component store's health.
Finally, the DISM /Online /Cleanup-Image /RestoreHealth command both scans the component store for corruption and attempts to repair them automatically. By default, RestoreHealth uses Windows Update to obtain the necessary system files needed to repair the component store. The Windows component store is a protected internal repository that contains important system files. Windows requires these files to service, update and customize the operating system.
What to do if DISM fails to repair your Windows installation?
Sometimes system file damage can also break Windows Update, preventing DISM from downloading replacement files. When this happens, you can use an official Windows installation media to supply DISM with the necessary repair files. You can download a Windows ISO from Microsoft's official download page. Once downloaded, right click the ISO file and select mount. Windows will create a virtual drive for the ISO, assign it a drive letter and make its contents available.
Next, you'll need to check the Windows editions available in the downloaded installation media. You can do that by launching the command prompt as an administrator and running the DISM /Get-ImageInfo /ImageFile:D:sourcesinstall.wim command. This command lists the Windows editions available on the installation media along with their index numbers. Make a note of the index number corresponding to your installed edition before proceeding to the next step.
Now, run the DISM /Online /Cleanup-Image /RestoreHealth /Source:WIM:D:sourcesinstall.wim:6 /LimitAccess command. Replace D: with the drive letter assigned to the mounted Windows ISO and 6 with the index number corresponding to your Windows edition. This directs DISM to use the installation media as its repair source instead of downloading files from Windows Update.
Once DISM completes its operation, run the sfc /scannow command to repair damaged or missing system files. Microsoft recommends running the DISM repair utility before System File Checker (SFC) because DISM repairs the Windows component store, which SFC relies on to replace corrupted system files.