Use DISM to fix issues SFC can't
A common suggestion on Windows support forums is to scan the system for file integrity issues using the command sfc /scannow which you may run on the active system but also on external drives.
SFC, which stands for System File Checker, is a built-in administrative tool to verify the integrity of operating system files and to repair files that are corrupt, damaged or changed.
SFC scans have three possible outcomes:
- The scan did not find any issues.
- The scan did find issues and fixed them.
- The scan did find issues and couldn't repair them (Windows Resource Protection found corrupt files but was unable to fix some of them).
Note: It is recommended that you do a full backup of the Windows system partition before you run DISM. Use free backup solutions such as Macrium Reflect, Veeam Endpoint Backup, or other backup tools.
Use DISM if SFC /Scannow fails to correct issues
The screenshot displayed above shows a result where SFC was unable to correct corrupt files that it detected.
SFC may also correct issues but it may not resolve the issue that you tried to correct in first place by running it.
DISM comes to the rescue in these situations. Deployment Image Servicing and Management (DISM)Â is a command line program for Windows that is used for a variety of purposes.It is available in all versions of Windows starting with Windows 7 and Windows Server 2008
You need to run DISM from an elevated command prompt:
- Tap on the Windows-key to bring up the start menu.
- Type cmd.exe and wait for the results to populate.
- Right-click on the result named cmd.exe and select "run as administrator" to run it with elevated privileges.
DISM can be run in dry-mode to reveal corruption without attempting to fix issues found. I recommend that you check the health first to find out if corruption exists before you run repair operations.
Dism /Online /Cleanup-Image /CheckHealth
The command checks the image for the corruption flag and returns its findings to you but does not run repair operations.
The scan should not take longer than a second or two. Previous operations may have flagged the image as corrupt.
Dism /Online /Cleanup-Image /ScanHealth
The command scans for component store corruption but does not correct any issues.
The scan takes longer to complete and the findings of the scan are returned in the command prompt window.
DISM /Online /Cleanup-Image /RestoreHealth
The /RestoreHealth parameter runs a scan for corruption and attempts to repair any issues that it finds automatically.
The scan takes longer to complete if corruption is found during the scan of the image. Note that the operation may appear stuck at times but this is no cause for concern as scanning should commence after a moment automatically.
If the scan finds corruption, it attempts to correct the issue using Windows Update by default.
DISM Advanced commands
- To repair an offline image: Dism /Image:C:\offline /Cleanup-Image /RestoreHealth
- To use a different repair source: Dism /Online /Cleanup-Image /RestoreHealth /Source:d:\test\mount\windows
- To prevent the use of Windows Update:Â /LimitAccess as a parameter.
You can specify a different source using the Group Policy.
Do the following for that:
- Tap on the Windows-key to bring up the start menu.
- Type gpedit.msc and hit the Enter-key to open the Group Policy Editor. Note that it is only available in professional or Enterprise editions of Windows.
- Go to Computer Configuration > Administrative Templates > System.
- Double-click on Specify settings for optional component installation and component repair.
- Set the policy to enabled, and configure it accordingly.
- You need to specify an alternate source, and may block use of Windows Update. Systems configured to use WSUS by default may be configured to use Windows Update instead for repair operations.
Dism using PowerShell
You may use DISM in Windows PowerShell as well. The commands are slightly different.
- CheckHealth: Repair-WindowsImage -CheckHealth
- ScanHealth: Repair-WindowsImage -ScanHealth
- RestoreHealth: Repair-WindowsImage -RestoreHealth
DISM Instructional Video
- Analyze and clean the WinSXS folder
- Dism++ Windows optimizer with impressive functionality
- The Winsxs Folder Explained
- Windows Repair 4.0 released: repair Windows software
- Windows Repair Toolbox review
Thanks a lot for the info ! There is a great app with GUI : Dism++
Although Dism command exists on Windows7 it doesn’t work with those options, maybe someone could explains how to repair on Win7?
Simple, Use DISM++
Yes but DISM++ is limited by the capabilities of the OS. I’ve tried removing superseded components on Windows 8 (the same as you can with Windows 8.1), but it won’t perform tasks that the OS version can’t support.
DISM++ in no more than a CCleaner and can’t perform any of DISM features.
Download Windows ADK to get an up-to-date DISM tool:
Please note some DISM repair options are not available on older OS (ie Win7), it won’t harm your OS though :)
Thanks for the article Martin. I wondered what DISM was for.
Great article. Sfc is almost useless now days it seems. I will remember to try this mor often.
SFC stands for System File Checker not ‘System File Scan’ as per the article description. One point deducted from each reader who never noticed and one from the author :)
I prefer to use:
prior to using the scannow switch.
(which notifies the user of errors but, does not correct them, so I can investigate further.)
You are right of course, sorry for that. Fixed it!
Nice to keep things correct to uphold your reputation.
Many thanks for the article :)
Martin thanks for the article please fix DISM commands mentioned in it. it seems that they need to be like this:
CheckHealth: Repair-WindowsImage -Online -CheckHealth
ScanHealth: Repair-WindowsImage -Online -ScanHealth
RestoreHealth: Repair-WindowsImage -Online -RestoreHealth
Sysnative’s SFCFix is a good alternative, and fixes some things SFC and DISM cannot…
Expand Step 4 for the download link.
Is it possible to schedule SFC & DISM tasks to be performed on a regular basis as a preventative way? How is ADK compare to SFC/DISM ?
i got a problem as error 1117 while dism scan health comand
You’re partially wrong about running DISM commands in Powershell (at least for windows 8.1)… Yes you can do it, but you just use the same commands as you do in Command Prompt, I tried using the commands you listed for Powershell and it just came back with errors every time however, when I used the Command Prompt commands it ran fine.
“the checkhealth option is not recognized in this context.”
I am struggling to use DISM in any meaningful way, which is no doubt due to my lack of understanding — or misunderstandings.
Background of the current problem — though my questions are general:
I have the harddrive from a computer that will not boot up but can get into the recovery environment (or I can boot off a Windows 10 installation memory stick).
I have performed bootrec /fixmbr (which reports successful), bootrec /fixboot (which reports Access Denied) and bootrec /ScanOS which reports no Windows installations found, although the Windows partition and folder can be accessed just fine. I ran
bcdboot C:\Windows /s S:
where the OS partition had been assigned the letter C: and the 100MB FAT32 partition S:
As a result of that, it now boots as far as a stopcode 0xc000021a, which could be due to corruption of WinLogon or Client Server-Run Time Subsystem (CSRSS) or of a driver, so I am trying to check the install for integrity.
I have removed the hard drive and stuck it in my PC. The Windows partition is mounted as H:
sfc offline scan says ‘Windows Resource Protection could not perform the requested operation’. Chdsk /r says no issues found.
My questions are:
1. Is the ‘guest’ hard drive offline as far as DISM is concerned? In my head, the definition of ‘online’ is the Windows installation that is currently running (my own PC in this case) and ‘offline’ is everything else — but am I right?
I base that assumption in part on the fact that if you use the /online switch, there is no way to specify where the affected Windows folder is, so it uses C:\
* I am aware that there are files that IT departments use to re-image their PCs and that they can modify those images, but that is NOT what I am doing: I am trying to repair a windows installation.
2. How do you tell DISM where Windows is? I tried
DISM /Image:H:\windows /Cleanup-Image /RestoreHealth and it says:
Unable to access the image.
Make sure that the image path and the Windows directory for the image exist and you have Read permissions on the folder.
– I do have Read permission for H:\Windows and can read files in the WinSXS folder.
* I wonder about that bit about Read permissions. Wouldn’t it need Write? Or is it referring to my own Windows folder there?
I also tried just H:\ instead of H:\Windows (same error),
Dism /Image:H:\offline /Cleanup-Image /RestoreHealth (same) and tried
Dism /Image:H:\windows /Cleanup-Image /RestoreHealth /Source:c:\windows
with the same error.
The only thing that gave a different error was
Dism /Image:H:\ /Cleanup-Image /RestoreHealth /Source:c:\windows
That backslash after the H: meant it said
The cleanup-image option is unknown.
Dism /Image:H: /windir:H:\windows /Cleanup-Image /RestoreHealth gives
Unable to access the image.
3. The documentation says that the source for DISM must match the installation in version and language. My PC is on Win10 2004, but I do not know which version the broken install is. How can you tell, given that you cannot start it up?
Grateful for any help. Thanks.