What is the purpose of the
/RestoreHealth parameter and the
- How do they correlate to one another?
- In what order should they be run?
- Why does the order sequence matter when executing either?
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
The Component Store [
%WinDir%\WinSxS] maintains a backup copy of all Windows system files;
DISM manage two separate, vital pieces of the Component Store and OS, with
SFC relying entirely upon what
DISMhas two functions
/RestoreHealthrelying solely upon
/StartComponentCleanup: Cleans the Component Store of any broken hard links
/RestoreHealth: Verifies and fixes any corruption in the Component Store by verifying it's system file backups against known good copies from the Windows Update servers through hash comparison; while an offline method does exist [below], it may not always fix the corruption
Dismdid not have this functionality until Windows 8
SFCalways assumes the Component Store is not corrupted and is why the
/RestoreHealthparameter (Windows 7: SUR) should always be run prior to
SFC; not doing so allows a corrupted Component Store to potentially replace a good system file with a corrupted one or fail to fix corruption within
/ScanNow: Verifies and fixes any corruption within
%WinDir%by verifying against the known good copies within the Component Store through hash comparison
SFC must be executed in the order listed, as each relies upon what the preceding does:
(Windows 7: skip to #3)
The Component Store should always be cleaned prior to running Windows Update, after an issue with Windows Update, and at least once a month, as it becomes dirty over time from updates occasionally breaking hard links.
# Windows ≥8: # Online (while booted to Windows): Dism /Online /Cleanup-Image /StartComponentCleanup # Offline (while booted to WinPE/WinRE): Dism /Image:"D:\Windows" /Cleanup-Image /StartComponentCleanup # C: is usually not the drive letter in WinPE/WinRE # To ascertain: DiskPart → Lis Vol → Exit
Requires an internet connection, else the offline method will be required:
# Windows ≥8: # Online (while booted to Windows): Dism /Online /Cleanup-Image /RestoreHealth # Offline (while booted to WinPE/WinRE): Dism /Image:"D:\Windows" /Cleanup-Image /RestoreHealth
install.wimfrom the Windows Install ISO for the installed version (v1909, v2004, etc.):
Dism /Get-ImageInfo /ImageFile:"Z:\sources\install.esd"
# Online (while booted to Windows): # ESD: Dism /Online /Cleanup-Image /RestoreHealth /Source:esd:"Z:\sources\install.esd":6 /LimitAccess # WIM: Dism /Online /Cleanup-Image /RestoreHealth /Source:wim:"Z:\sources\install.wim":6 /LimitAccess # Offline (while booted to WinPE/WinRE): Dism /Image:"D:\Windows" /Cleanup-Image /RestoreHealth /Source:esd:"Z:\sources\install.esd":6 /LimitAccess
%WinDir%\Logs\DISM\dism.logfrom the bottom up
%WinDir%\Logs\CBS\CheckSUR.log(How to fix SUR errors)
# Online (while booted to Windows): Sfc /ScanNow # Offline (while booted to WinPE/WinRE): Sfc /ScanNow /OffBootDir=D:\ /OffWinDir=D:\Windows # C: is usually not the drive letter in WinPE/WinRE # To ascertain: DiskPart → Lis Vol → Exit
# Cmd: FindStr /c:"[SR]" "%WinDir%\Logs\CBS\CBS.log" > "%UserProfile%\Desktop\SFCdetails.log" # PowerShell: FindStr /c:"[SR]" "$env:WinDir\Logs\CBS\CBS.log" > "$env:UserProfile\Desktop\SFCdetails.log"
I run these weekly via Task Scheduler to help prevent random issues from occurring:
To import into Task Scheduler:
SchTasks /Create /Xml "%UserProfile%\Downloads\<task_name>.xml" /Tn "\Custom\Task Name" /Ru "%ComputerName%\%UserName%"
Register-ScheduledTask -Xml (Get-Content '$env:UserProfile\Downloads\<task_name>.xml' | Out-String) -TaskName "Task Name" -TaskPath "\Custom\" -User $env:ComputerName\$env:UserName –Force