/

How to Use the DISM Command for Windows Image Deployment and Servicing

by Makenzie Buenning, IT Editorial Expert
reviewed by Stan Hunter, Technical Marketing Engineer
How to Use DISM Command for Windows Image Deployment and Servicing blog banner image
How to Use DISM Command for Windows Image Deployment and Servicing blog banner image

Try our #1 rated endpoint management platform on G2

NinjaOne dashboard screenshot

Automate the Hardest Parts of IT

Key Points

  • DISM (Deployment Image Servicing and Management) is a built-in Windows command-line tool used to service and manage Windows image files offline or on a live OS.
  • Mounting and unmounting images: Run /Commit to save changes or /Discard to roll them back.
  • Adding and removing drivers: Use /Add-Driver and /Remove-Driver, making it easy to support new hardware or resolve driver conflicts before deployment.
  • Applying updates: Run /Add-Package to ensure deployed images include the latest security patches before they reach an endpoint, reducing post-deployment update time and exposure.
  • Repair a corrupted Windows image: Execute /CheckHealth, /ScanHealth, and /RestoreHealth in this order, then follow with sfc /scannow to fix individual system files.

A Windows image file is a compressed file containing the Windows operating system and software, settings, and configurations for your hard drive. This file is like a photocopy of the drive and can be used for a number of reasons, including backing up your system or repairing it if something goes wrong with your operating system or hard drive. 

At some point, you’ll need to modify, repair, or install updates to your Windows image. That’s when you’ll need the DISM command. 

Protect crucial files and entire systems with NinjaOne’s reliable backup software.

See what NinjaOne Windows Endpoint Backup has to offer.

Introduction to DISM command

The Deployment Image Servicing and Management (DISM) command is valuable for system administrators because it makes fixing corrupted or missing Windows system files easier. Knowing how to use the Windows DISM command can greatly enhance your ability to deploy and service Windows images effectively.

What is Deployment Image Servicing and Management (DISM)?

DISM is a command-line tool built into Windows systems. It is used for servicing and managing Windows images, including deployment, updates, and repair. With its extensive capabilities, the DISM command allows you to perform various operations on Windows images, such as mounting and unmounting images, adding or removing drivers, enabling or disabling features, applying updates, and more. 

Why use the DISM command?

The DISM command provides many benefits and advantages for Windows image deployment and servicing. Here are a few reasons why you should know how to use the Windows DISM command:

  • Efficiency and flexibility: The DISM command offers a flexible and efficient way to manage Windows images. It allows you to perform various operations on images without a graphical user interface (GUI), making it suitable for automation and scripting.
  • Compatibility and integration: Since DISM is an official Microsoft tool that is built into Windows systems, it’s fully compatible with the Windows operating system and seamlessly integrates with other Windows tools and technologies. 
  • Advanced features: The DISM command provides advanced features and functionalities not available through other tools or commands, allowing you to add custom drivers, apply updates, enable or disable features, or perform other image servicing tasks.
  • Troubleshooting and repair: DISM offers powerful troubleshooting and repair capabilities, helping you identify and fix issues with Windows images, such as corrupted files, missing components, and more.

Leveraging the DISM command lets you streamline your Windows image servicing for a more efficient and reliable IT infrastructure.

Using the DISM command for Windows image deployment

Now let’s dive into how to use the DISM command for Windows image deployment. DISM provides a wide range of options and parameters to perform various operations on Windows images. Here are some common use cases for the Windows DISM command:

Mounting and unmounting images

One of the fundamental operations you can perform with the DISM command is mounting and unmounting Windows images. Mounting an image lets you access its contents and make changes to it. Once you’ve made the necessary modifications, you can unmount the image to apply the changes and prepare the updated image for deployment.

To mount an image using the DISM command, you can use the following syntax:

DISM /Mount-Image /ImageFile:<path_to_image> /Index:<image_index> /MountDir:<mount_directory>

In this example, <path_to_image> is the path of the Windows image file, <image_index> is the index number of the image within the file, and <mount_directory> refers to the directory where you want to mount the image.

Adding and removing drivers

Use the DISM command to add or remove device drivers from a mounted or offline Windows image. This can be useful when supporting new hardware or troubleshooting driver-related issues.

Add a driver to a Windows image using the following command:

dism /image:<image_path> /add-driver /driver:<driver_path>

Here, <image_path> refers to the path to the Windows image, and <driver_path> is the path to the driver file you want to add.

To remove a driver from a Windows image, you can use the following command:

dism /image:<image_path> /remove-driver /driver:<driver_name>

In this case, <driver_name> is the name of the driver you want to remove.

Applying updates

Keeping your Windows images updated is crucial for security and performance reasons. The DISM command allows you to apply updates to a Windows image online or offline easily. This ensures that the image includes the latest patches and fixes.

Use the following command to apply updates to a mounted or offline Windows image:

dism /image:<image_path> /add-package /packagepath:<update_path>

Here, <image_path> is the path to the Windows image, and <update_path> is the path to the update package you want to apply.

Additional DISM command-line options are available in Microsoft’s Windows Learn database.

Repairing a Corrupted Windows Image

One of the most common reasons IT administrators use DISM is to repair a corrupted or unhealthy Windows installation. You can use these three DISM commands, but you should be run them in this specific order:

  1. Check image health (read-only, no changes made):

DISM /Online /Cleanup-Image /CheckHealth

  1. Scan for corruption (no changes made, takes several minutes):

DISM /Online /Cleanup-Image /ScanHealth

  1. Repair the image (downloads replacement files from Windows Update):

DISM /Online /Cleanup-Image /RestoreHealth

The /RestoreHealth command connects to the Windows Update server to download and replace any corrupted files it detects. If the endpoint has no internet access, you can point DISM to a local Windows installation media as the repair source:

DISM /Online /Cleanup-Image /RestoreHealth /Source:D:\Sources\install.wim /LimitAccess

DISM /RestoreHealth only repairs the Windows component store (WinSxS). If system files themselves are corrupt, you will have torun sfc /scannow to restore these files after DISM completes the scan. The System File Checker (SFC) tool relies on the component store that DISM repairs.

Windows DISM command best practices

The DISM command is a helpful tool, and following best practices will help ensure smooth and successful Windows image deployment and servicing. Here are some best practices to keep in mind when using the DISM command:

  • Use the latest version: Always verify that you’re using the latest version of the Windows DISM command. Microsoft regularly releases updates and improvements for DISM to enhance its capabilities and address any known issues.
  • Verify image integrity: Before performing any operations on a Windows image, it’s a good idea to verify its integrity. You can use the Windows DISM command with the /checkhealth parameter to check the image’s health and identify any corruption or issues. Note that /checkhealth only identifies issues; it doesn’t fix them.
  • Keep backup copies: Whenever you make changes to a Windows image using the DISM command, you should keep backup copies of the original image to ensure that you can easily revert back to the original state if any issues arise.
  • Document changes: Document any changes you make when making modifications to Windows images using the DISM command. This helps with tracking and troubleshooting any issues that may arise later.
  • Disable antivirus tools: Antivirus and antimalware tools can block or impact some DISM commands. You can configure your computer to skip the mount folder during scans.

Limitations and alternatives to DISM command

While the DISM command is a useful tool for servicing Windows images, it does have some limitations. Here are a few limitations to be aware of:

  • Complexity: The DISM command can be complex for beginners or users unfamiliar with command-line tools, and it requires a good understanding of the structure of Windows images.
  • Compatibility: The DISM command is primarily designed for Windows systems and may not be compatible with other operating systems. If you need to perform image deployment and servicing on non-Windows systems, you may need to explore alternative tools or methods.
  • Learning curve: Mastering the DISM command requires time and effort to understand various options, parameters, and syntaxes. If you want to use it effectively, plan to invest time in learning and practicing the DISM command.

If you find the DISM command too complex or if you are working with non-Windows systems, there are alternatives available. 

Using the DISM command to simplify Windows

The DISM command is a versatile tool offering a wide range of features and capabilities that can greatly enhance your ability to manage and deploy Windows images. The DISM command and other command-line operations can save you time and effort in managing the Windows operating system. 

Reduce time spent on managing your Windows devices and backups by 95% with NinjaOne.

Try NinjaOne Windows endpoint management for free.

FAQs

SFC (System File Checker) scans and repairs individual Windows system files, while DISM repairs the Windows component store (WinSxS) that SFC depends on. If SFC reports errors it cannot fix, it usually means the component store itself is corrupt — run DISM /RestoreHealth first to repair it, then re-run sfc /scannow. The two tools complement each other; DISM does not replace SFC.

Typically, it would take around 10 to 30 minutes, depending on the extent of corruption and your internet connection speed. The progress bar may appear to stall at certain percentages (particularly around 20% and 65%, but do not close the window. The command will complete on its own.

It depends on which files are corrupted. Running DISM /Online /Cleanup-Image /RestoreHealth only repairs the Windows component store, which is the repository Windows uses to store and recover system components. If the component store itself is damaged or contains corrupted entries, RestoreHealth fixes it by downloading clean replacement files from Windows Update. However, DISM does not directly repair individual Windows system files. You will need to use the System File Checker (SFC) tool by running sfc /scannow to repair any corrupted system files. However, the SFC draws from the component store DISM that repairs, so you need to run your DISM /RestoreHealth command first.

You might also like

Ready to simplify the hardest parts of IT?

NinjaOne Terms & Conditions

By clicking the “I Accept” button below, you indicate your acceptance of the following legal terms as well as our Terms of Use:

  • Ownership Rights: NinjaOne owns and will continue to own all right, title, and interest in and to the script (including the copyright). NinjaOne is giving you a limited license to use the script in accordance with these legal terms.
  • Use Limitation: You may only use the script for your legitimate personal or internal business purposes, and you may not share the script with another party.
  • Republication Prohibition: Under no circumstances are you permitted to re-publish the script in any script library belonging to or under the control of any other software provider.
  • Warranty Disclaimer: The script is provided “as is” and “as available”, without warranty of any kind. NinjaOne makes no promise or guarantee that the script will be free from defects or that it will meet your specific needs or expectations.
  • Assumption of Risk: Your use of the script is at your own risk. You acknowledge that there are certain inherent risks in using the script, and you understand and assume each of those risks.
  • Waiver and Release: You will not hold NinjaOne responsible for any adverse or unintended consequences resulting from your use of the script, and you waive any legal or equitable rights or remedies you may have against NinjaOne relating to your use of the script.
  • EULA: If you are a NinjaOne customer, your use of the script is subject to the End User License Agreement applicable to you (EULA).