Repairing Windows System Files

55 views
Skip to first unread message

tbp1...@gmail.com

unread,
Jun 4, 2022, 5:57:21 PM6/4/22
to leo-editor
Sometimes Windows system files get corrupted.  This may happen because of a crash, or who knows why else.  It has happened to me several times.  Sometimes you won't even know of a problem.  Other times something won't work right and you can't see why.

There are a few ways to discover system file corruption and to have Windows repair them.  The two I have used are both command line programs to be launched from an administrative console.

1. sfc ("system file check").  Run it with this command line:

sfc /scannow

With this parameter, it will start an immediate scan and repair or replace damaged system files in place.  It will take some time, but you can keep working during the scan.

2. dism ("Deployment Image Servicing and Management tool").  Command line:

dism /online /cleanup-image /restorehealth

Again the scan will take time and you can keep working.  The programs may not tell you, but it's probably a good idea to reboot if they have fixed a problem.

I don't know when to prefer one over another.  I run sfc first, perhaps because it's easier to remember the command line.  If problems are found and claimed to be fixed, it's probably good to repeat the scan.

I mention these utilities even though they are not Leo-specific, because it's hard to discover them online and I have found them helpful.

Edward K. Ream

unread,
Jun 6, 2022, 4:12:14 AM6/6/22
to leo-editor
On Sat, Jun 4, 2022 at 4:57 PM tbp1...@gmail.com <tbp1...@gmail.com> wrote:

There are a few ways to discover system file corruption and to have Windows repair them.  The two I have used are both command line programs to be launched from an administrative console.

Thanks for these tips.

Edward

David Szent-Györgyi

unread,
Jun 12, 2022, 8:13:44 AM6/12/22
to leo-editor
On Saturday, June 4, 2022 at 5:57:21 PM UTC-4 tbp1...@gmail.com wrote:
I don't know when to prefer one over another.  I run sfc first, perhaps because it's easier to remember the command line.  If problems are found and claimed to be fixed, it's probably good to repeat the scan.

I mention these utilities even though they are not Leo-specific, because it's hard to discover them online and I have found them helpful.

If my reading of the explanation below is correct, it is best to use dism before using sfc. The following is an excerpt from Using the Deployment Image Servicing and Management Tool (DISM) to repair the Windows System Store.

The System File Checker tool can be used to repair corrupted system files. For more information on how to use the tool, refer to the following Microsoft article: Use the System File Checker tool to repair missing or corrupted system files. The System File Checker tool compares those files against the .wim store that is saved on the system (not to be confused with the Windows Software Store app where you can purchase software for Windows). If this store is corrupted, the repairs may not resolve the problems that the system is having. The DISM tool has some modifiers that can scan and repair the .wim store based on parent copies stored on Microsoft’s update servers, making it useful to run in conjunction with a system file check.

tbp1...@gmail.com

unread,
Jun 12, 2022, 8:19:23 AM6/12/22
to leo-editor
I had one case where I had to run sfc several times before it reported no problems.  Then I ran dism and it found (and repaired) more.  That seems to be in line with what you wrote.  I haven't studied all the command line options for the tool.

David Szent-Györgyi

unread,
Jun 12, 2022, 9:26:35 AM6/12/22
to leo-editor
The terminology used with Microsoft's dism gives specific new meanings to terms widely used in broader contexts. Keep in mind these specific meanings: 

WIM file a "Windows image" file, used for deployment of Windows Vista and more recent versions of Windows; extension .wim
VHD and VHDX files "Virtual hard disk", other types of file containing disk images; extensions .vhd and .vhdx
/Online targets the installation of Windows that is in use
/Image targets a specified WIM file , VHD, or VHDX file. 
store from British usage, a place in which items are routinely kept; distinct from the North American usage for a shop)

Links of interest: 
Repair a Windows Image; includes dism usage for checking whether an image is repairable, for detecting corruption as well as for making repairs
Windows Imaging Format, on Wikipedia 
VHD (file format), on Wikipedia, covering VHDX as well
DISM Overview, Microsoft's documentation, not written for the general reader

tbp1...@gmail.com

unread,
Jun 12, 2022, 10:03:54 AM6/12/22
to leo-editor
The help text for dism is mostly unintelligible to ordinary computer users.  You would have to know a lot of Microsoft-specific OS details to make sense of most of it.  The only help command likely to be helpful for most of us is

dism /online /cleanup-image /?

David Szent-Györgyi

unread,
Jun 12, 2022, 3:14:06 PM6/12/22
to leo-editor
On Sunday, June 12, 2022 at 10:03:54 AM UTC-4 tbp1...@gmail.com wrote:
The help text for dism is mostly unintelligible to ordinary computer users.  You would have to know a lot of Microsoft-specific OS details to make sense of most of it.  The only help command likely to be helpful for most of us is

dism /online /cleanup-image /?

I am not in front a WIndows computer, so I cannot see the response to that command. Am I correct that the response is display of the options for performing cleanup or recovery operations on the operating system as installed on the computer that is providing the command line?

David Szent-Györgyi

unread,
Jun 12, 2022, 3:19:29 PM6/12/22
to leo-editor
On Sunday, June 12, 2022 at 9:26:35 AM UTC-4 David Szent-Györgyi wrote:

Links of interest: 
Repair a Windows Image; includes dism usage for checking whether an image is repairable, for detecting corruption as well as for making repairs
Windows Imaging Format, on Wikipedia 
VHD (file format), on Wikipedia, covering VHDX as well
DISM Overview, Microsoft's documentation, not written for the general reader

I add another link, which should come first in the list: 

Use the System File Checker tool to repair missing or corrupted system files, which covers Windows Vista through Windows 10. This is a task-centered procedure that explains just enough of the purpose of each command that one enters. The article makes no mention of Windows 11, alas.  

tbp1...@gmail.com

unread,
Jun 12, 2022, 3:35:17 PM6/12/22
to leo-editor
Yes, that's right.  But there is another wrinkle. You cannot get help on, e.g., "/cleanup-image", or even learn that it exists, unless you prefix the help command with the "/online" .  It seems that dism can do so many things that the help system had to become complicated, too.

David Szent-Györgyi

unread,
Jun 12, 2022, 4:08:54 PM6/12/22
to leo-editor
On Sunday, June 12, 2022 at 3:35:17 PM UTC-4 tbp1...@gmail.com wrote:
You cannot get help on, e.g., "/cleanup-image", or even learn that it exists, unless you prefix the help command with the "/online" .  It seems that dism can do so many things that the help system had to become complicated, too.

You mean that one has to enter the command dism /?

then dism /online /?

then dism /online /cleanup-image /?

The same is true of PowerShell's built-in help: one has to drill down, one argument at a time. One must know which argument to give at each step. That would be easier if Microsoft chose more wisely when coining names!

tbp1...@gmail.com

unread,
Jun 12, 2022, 11:01:21 PM6/12/22
to leo-editor
You don't have to do each step separately first, but if you don't give the right leadin, you won't even see the help options.  E.g., if you type

dism  /?

then "/cleanup-image" will not be one of the options listed.  "/online" will be listed, and you have to know to ask for 

dism /online /?

and then "/cleanup-image" will be be listed.  If you want to discover "/checkhealth ", "/scanhealth", or "restorehealth" you have to include "/cleanup-image":

dism /online /cleanup-image  /?
Reply all
Reply to author
Forward
0 new messages