How To Use The DISM Command to Repair Windows 10: A Step-By-Step Guide

Last Update: Jun 06, 2024 | Published: Jul 05, 2018

Windows-11-notebook-tablet

SHARE ARTICLE

Learn how to use the DISM command in Windows 10 and Windows 11 to troubleshoot and fix common issues with your Windows operating system and key system files. Follow our step-by-step guide to learn all about System File Checker (SFC), DISM, and to gain some knowledge about what your ‘local Windows image’ is.

What is the DISM command used for?

DISM stands for Deployment Image Servicing and Management. This is a command-line tool used to create, modify, or repair system images, including Windows 10 and Windows 11. It is used for various types of Windows system images including the Windows Recovery Environment, Windows Setup, and Windows PE (WinPE). The system image is referenced whenever routine checks on system files are performed. There are a few utilities included in Windows that allow you to scan your system for any potential data corruption.

Let me explain how this works in the next section.

How do I scan my Windows system for errors?

There are two main command-line utilities included in Windows to scan the local system for any corruption of key system files. These include all the files to maintain Windows and its robustness. These utilities are often used as a first step in troubleshooting general issues with Windows.

Using SFC to scan for errors

If your Windows system is having trouble booting or if you’re trying to resolve a specific error, you can try the SFC command tool. The System File Checker will scan the integrity of all protected system files and replace incorrect versions with correct Microsoft versions. It uses relied-upon images on the local system (more on this in a moment).

Let me show you how it works. Open an administrative command prompt and run the following command:

sfc /scannow
sfc /scannow running in command line
‘sfc ‘/scannow’ and the corresponding ‘CBS.LOG’ logfile (Image Credit: Michael Reinders/Petri.com)

Well, look at that. It found corrupt files and repaired them. You’ll see the corresponding CBS.LOG file in the screenshot above which shows detailed steps the utility took to complete the scan and repairs. And don’t worry too much about the fact that it found corruption. It’s a little more commonplace than you may think.

Using DISM to scan for errors

The SFC utility above used the local image (install.wim) to copy the repaired files back into Windows. But what happens if that local image is damaged or corrupted in some way? This is where DISM comes to save the day. If the System File Checker reports problems with the local image, you can use DISM to make repairs to the local images, most often from online repositories. Let me go through the process next.

How to use DISM to scan and repair your local Windows 10/11 Image

The DISM tool includes three main switches that can help you repair a system image. These are:

  1. /CheckHealth
  2. /ScanHealth
  3. /RestoreHealth

You will want to make sure you use them in this order. Let’s first ‘check the health’ of our image below.

Using the /CheckHealth switch

The first switch is to check the health of an image, completely non-destructive. Think of it as a ‘read-only’ phase. Open your administrative command prompt, or Windows Terminal to run this command and press Enter.

DISM /online /Cleanup-image /Checkhealth
Running DISM command with the '/CheckHealth' switch
Running DISM with the ‘/CheckHealth’ switch (Image Credit: Michael Reinders/Petri.com)

Well, piece of cake. As you can see, we’re good. Let’s move on to the next one.

Using the /ScanHealth switch

This is a little more robust. It performs a more advanced scan to dig deeper into the image itself to find any issues. Please run this command to initiate the scan.

DISM /online /Cleanup-image /ScanHealth

On my rather basic Windows 10 VM in my Hyper-V lab, this command took about 4 minutes to complete.

Using the DISM command '/ScanHealth' switch
Using the DISM ‘/ScanHealth’ switch (Image Credit: Michael Reinders/Petri.com)

There, everything is looking very good. Still 10 for 10.

Using the /RestoreHealth switch

Because no corruption was detected, the next command will likely be nice and swift. However, for completeness, the ‘RestoreHealth’ switch is used to repair issues with your local image. If any corruption or missing files are detected, DISM will connect to ‘Windows Update’ and download any needed files from a trusted source online.

Run this command to attempt repairs to the image.

DISM /online /Cleanup-image /Restorehealth
Using the DISM command '/RestoreHealth' switch
Using the DISM ‘/RestoreHealth’ switch (Image Credit: Michael Reinders/Petri.com)

Again, a nice clean system. Obviously, on a fairly ‘worn’ system with multiple application installs, repairs, uninstalls, etc. you are bound to find items that need repairing. This is the most trustworthy solution in your arsenal if you hope to avoid re-imaging your machine.

Another scenario that the DISM tool helps is when you encounter component store corruption. The component store on a Windows system is the C:\Windows\WinSxS folder. 99% of the time you want to leave this alone, as it is critical to keep Windows running. You can look into additional options related to the ‘/Cleanup-image’ switch to repair this corruption.

Repairing your local image with Microsoft assistance

So, what do you do if the command experiences issues with repairing files? What if the computer you’re attempting repairs on is not connected to the Internet (network)? You need to adjust your tactics by downloading, on another computer, a fresh, trusted Windows 10 ISO file. Let me show you how.

Downloading the Media Creation Tool

The first step is download the Media Creation Tool from Microsoft’s download servers. This tool lets you create installation media from a central trusted source.

You can start here on the ‘Download Windows 10’ website. Under ‘Create Windows 10 installation media‘, click the ‘Download Now‘ button to download the tool.

The 'Download Windows 10' download site on microsoft.com
The ‘Download Windows 10’ download site on microsoft.com (Image Credit: Michael Reinders/Petri.com)

After downloading the file, we’ll move into running it!

Downloading a new Windows 10 .ISO file

In your Downloads folder, double-click on the ‘MediaCreationTool_22H2.exe‘ file.

Opening the Media Creation Tool
Opening the Media Creation Tool (Image Credit: Michael Reinders/Petri.com)

You can agree to the license terms and click Accept.

Choosing to upgrade your PC or create install media. We are choosing the latter.
Choosing to upgrade your PC or create install media. We are choosing the latter. (Image Credit: Michael Reinders/Petri.com)

On the ‘What do you want to do?‘ page, choose the second option – ‘Create installation media (USB flash drive, DVD, or ISO file) for another PC‘.

Choosing the language, architecture (32-bit, 64-bit, etc.), and Edition
Choosing the language, architecture (32-bit, 64-bit, etc.), and Edition (Image Credit: Michael Reinders/Petri.com)

The next screen asks you to choose the Language, Edition, and Architecture. Make your choices and click Next.

Choosing a USB flash drive or an ISO file. We will again choose the latter.
Choosing a USB flash drive or an ISO file. We will again choose the latter. (Image Credit: Michael Reinders/Petri.com)

On the ‘Choose which media to use’ screen, choose the second option again, ‘ISO file.’

The Download has begun...
The Download has begun… (Image Credit: Michael Reinders/Petri.com)

The tool will then open a standard Windows ‘browse’ window and ask you where you want to save the ISO file it will download. I chose the Downloads folder and kept the default filename, Windows.ISO.

The file will now be downloaded from Microsoft online servers. After the download completes, it will verify the file and save the ISO file where you specified.

The ISO file is downloaded.
The ISO file is downloaded. (Image Credit: Michael Reinders/Petri.com)

There, it finished and there’s the file.

Repairing your local image with a verified source (ISO)

Now that we have a known-good image file (the windows.iso file we downloaded), we have the option to repair the health of our local image using this certified file. Here are the steps you can use to complete the repairs when you run into this situation.

First, right-click on the windows.iso file and click Mount. This will ‘open’ the ISO file and allow Windows to access it as if a Windows installation DVD was inserted into a local DVD drive. Note the drive letter assigned to it (mine is E:).

Then, run this command to run DISM with the ‘/RestoreHealth’ switch using our new ISO file.

DISM /online /Cleanup-image /Restorehealth /Source:E:\sources\install.wim
Using our downloaded ISO file to perform a live repair of our local image using the DISM command
Using our downloaded ISO file to perform a live repair of our local image using the DISM command (Image Credit: Michael Reinders/Petri.com)

You have the option to limit the use of Windows Update when using the ‘/RestoreHealth’ option. If you also add the ‘/Limitaccess’ switch, the tool won’t go out to Windows Update to check for files, it will only use your local source file (ISO).

Conclusion

The DISM command is an indispensable tool in Windows 10/11, especially for IT Pros and admins. We are given a robust set of tools and switches to bring back these systems to life, saving hours from re-imaging, re-installing applications, etc.

One quick note – although the potential repairs made by the tool are nearly always non-destructive, it is still a good idea to make a full system backup before performing these steps.

Thank you for reading. If you have any comments or questions, please leave a note in the comments below!

SHARE ARTICLE