Repair and Service Windows Images with DISM

Use DISM to repair Windows, clean the component store, manage features and drivers, and service offline WIM images.

Repair a Windows Image

DISM Command-Line Options

Use System File Checker

Before You Start

Deployment Image Servicing and Management, or DISM, can repair the running Windows component store and service offline Windows images. In DISM terminology:

  • /Online targets the Windows installation that is currently running.
  • /Image:C:\Mount targets an offline Windows installation whose root is mounted at C:\Mount.
  • Image-management commands such as /Mount-Image operate on a WIM, VHD, VHDX, or FFU file rather than using /Online.

Open Windows Terminal, PowerShell, or Command Prompt as an administrator. Back up important data before modifying an offline image, drivers, features, or Windows edition. Do not interrupt DISM while it is committing an image.

DISM records servicing details in C:\Windows\Logs\DISM\dism.log. System File Checker writes details to C:\Windows\Logs\CBS\CBS.log.

Repair the Running Windows Installation

Install available Windows updates and restart first. Then open an elevated terminal.

Check whether Windows has already marked the component store as damaged:

DISM.exe /Online /Cleanup-Image /CheckHealth

/CheckHealth reads the existing corruption flag; it does not perform a new scan. Run a complete scan when the quick check reports damage or Windows is behaving unexpectedly:

DISM.exe /Online /Cleanup-Image /ScanHealth

Repair the component store. Without /Source, DISM uses the repair source defined by policy and can contact Windows Update:

DISM.exe /Online /Cleanup-Image /RestoreHealth

After DISM completes successfully, repair protected system files from the restored component store:

sfc.exe /scannow

Microsoft recommends running DISM before SFC. Wait until each command finishes; apparent pauses at one percentage do not necessarily mean that the process has stopped.

Restart Windows after repairs, then verify the component store again:

DISM.exe /Online /Cleanup-Image /CheckHealth

Repair from Matching Installation Media

Use a local source when Windows Update is unavailable or DISM reports that source files could not be found. The installation media must match the installed Windows architecture, language, edition, and release. A source older than the installed servicing level might not contain the required components.

Mount the Windows ISO. The examples below assume that it appears as drive D:.

Determine whether the media contains install.wim or install.esd:

dir D:\sources\install.*

List the editions and indexes in a WIM:

DISM.exe /Get-WimInfo /WimFile:D:\sources\install.wim

Use the index that matches the installed edition. The following example uses index 6; replace it with the value reported for your media:

DISM.exe /Online /Cleanup-Image /RestoreHealth /Source:wim:D:\sources\install.wim:6 /LimitAccess

For media containing an ESD, inspect and use it instead:

DISM.exe /Get-WimInfo /WimFile:D:\sources\install.esd
DISM.exe /Online /Cleanup-Image /RestoreHealth /Source:esd:D:\sources\install.esd:6 /LimitAccess

/LimitAccess prevents DISM from contacting Windows Update. Omit it only when Windows Update should remain available as a fallback source.

Run SFC after the source-based repair succeeds:

sfc.exe /scannow

Analyze and Clean the Component Store

Analyze the WinSxS component store before deciding whether cleanup is useful:

DISM.exe /Online /Cleanup-Image /AnalyzeComponentStore

Remove superseded component versions:

DISM.exe /Online /Cleanup-Image /StartComponentCleanup

Do not manually delete files from C:\Windows\WinSxS.

DISM also supports the more aggressive /ResetBase option:

DISM.exe /Online /Cleanup-Image /StartComponentCleanup /ResetBase

After /ResetBase completes, installed update packages incorporated into the new base cannot be uninstalled. Use it only after the system and its updates have been tested and rollback is no longer required.

Manage Optional Windows Features

List feature names and their states:

DISM.exe /Online /Get-Features /Format:Table

Inspect one feature before changing it:

DISM.exe /Online /Get-FeatureInfo /FeatureName:Microsoft-Hyper-V-All

Enable a feature and all required parent features without restarting automatically:

DISM.exe /Online /Enable-Feature /FeatureName:Microsoft-Hyper-V-All /All /NoRestart

Disable a feature while retaining its payload:

DISM.exe /Online /Disable-Feature /FeatureName:Microsoft-Hyper-V-All /NoRestart

Feature availability depends on the Windows edition and hardware. Review the command result and restart when DISM reports that a reboot is required. Adding /Remove to /Disable-Feature removes the feature payload and can require a matching source when the feature is enabled again.

Check Windows Edition Information

Display the current edition identifier:

DISM.exe /Online /Get-CurrentEdition

Display supported target editions:

DISM.exe /Online /Get-TargetEditions

/Set-Edition is not a general downgrade or cross-family conversion tool. Microsoft documents online edition conversion with DISM for supported Windows Server paths. Confirm that the target appears in /Get-TargetEditions, obtain a valid key, review the license terms, and follow Microsoft’s Windows Server conversion guidance.

For a supported Server Standard-to-Datacenter conversion, the command has this form:

DISM.exe /Online /Set-Edition:ServerDatacenter /ProductKey:<product-key> /AcceptEula

Replace <product-key> with the valid key without publishing it in documentation, scripts, or logs. Edition conversion can require a restart and cannot be used to convert an Active Directory domain controller from an evaluation edition to retail.

Export Third-Party Drivers

Create a destination and export the third-party INF driver packages from the running installation:

mkdir C:\DriversBackup
DISM.exe /Online /Export-Driver /Destination:C:\DriversBackup

The export contains INF-style driver packages. It does not back up vendor installers, control applications, firmware tools, or every device-specific setting. Copy the result to separate storage and test it before relying on it for recovery.

List third-party drivers installed in the running system:

DISM.exe /Online /Get-Drivers /Format:Table

DISM supports /Add-Driver for offline Windows images, not for the running installation. Use Windows Update, Device Manager, or the vendor’s supported installer to add a driver to the current operating system.

Mount and Service an Offline WIM

These examples assume that a Windows ISO is mounted as D:, the writable image will be stored in C:\Images, and the empty mount directory is C:\Mount.

Create the working directories, copy the WIM from the read-only ISO, and remove its read-only attribute:

mkdir C:\Images
mkdir C:\Mount
copy D:\sources\install.wim C:\Images\install.wim
attrib -r C:\Images\install.wim

List the available indexes:

DISM.exe /Get-WimInfo /WimFile:C:\Images\install.wim

Mount the required index. This example uses index 6; replace it with the correct index:

DISM.exe /Mount-Image /ImageFile:C:\Images\install.wim /Index:6 /MountDir:C:\Mount /CheckIntegrity

Query the mounted image:

DISM.exe /Image:C:\Mount /Get-CurrentEdition
DISM.exe /Image:C:\Mount /Get-Features /Format:Table
DISM.exe /Image:C:\Mount /Get-Drivers /Format:Table

Add signed INF drivers from a directory and its subdirectories:

DISM.exe /Image:C:\Mount /Add-Driver /Driver:C:\DriversBackup /Recurse

Review the warnings. /Recurse can add unnecessary drivers and increase the image size. Do not use /ForceUnsigned for a production image.

Commit the changes and unmount the image:

DISM.exe /Unmount-Image /MountDir:C:\Mount /Commit /CheckIntegrity

To abandon all changes instead:

DISM.exe /Unmount-Image /MountDir:C:\Mount /Discard

Always choose either /Commit or /Discard. Back up the original WIM before servicing it and keep enough free disk space for the mount and commit operations.

Repair an Offline Windows Installation

In Windows Recovery Environment or Windows PE, drive letters can differ from normal Windows. Locate the offline installation before running repair commands:

dir C:\Windows
dir D:\Windows

If the offline Windows directory is D:\Windows, target its volume root:

DISM.exe /Image:D:\ /Cleanup-Image /CheckHealth
DISM.exe /Image:D:\ /Cleanup-Image /ScanHealth
DISM.exe /Image:D:\ /Cleanup-Image /RestoreHealth /Source:E:\RepairSource\Windows /LimitAccess

Replace both drive letters with the paths shown in the recovery environment. The repair source must match the offline operating system.

/RevertPendingActions exists for recovery from a boot failure caused by an incomplete servicing operation. It is unsupported against the running operating system and should be used only after diagnosing that specific recovery scenario.

Capture and Append a WIM Image

For deployment imaging, prepare the reference installation with Sysprep as required by the deployment plan, boot another operating system such as Windows PE, and capture the offline Windows volume. Do not capture an actively running system volume as a deployment image.

Capture the prepared C: volume to another drive:

DISM.exe /Capture-Image /ImageFile:D:\Images\Windows11.wim /CaptureDir:C:\ /Name:"Windows 11 Pro" /Description:"Reference image" /Compress:Max /CheckIntegrity /Verify

Append another prepared image to the existing WIM:

DISM.exe /Append-Image /ImageFile:D:\Images\Windows11.wim /CaptureDir:C:\ /Name:"Windows 11 Enterprise" /Description:"Reference image" /CheckIntegrity /Verify

The appended image must use the compression type already assigned to the WIM. Ensure that the destination has enough free space; running out of space during an append can corrupt the image.

Verify the resulting image indexes:

DISM.exe /Get-WimInfo /WimFile:D:\Images\Windows11.wim

Recover a Stale Mount

List known mount points first:

DISM.exe /Get-MountedImageInfo

Try to recover an image whose mount directory became inaccessible:

DISM.exe /Remount-Image /MountDir:C:\Mount

Use /Cleanup-Mountpoints only for corrupted mount resources that cannot be recovered or normally unmounted:

DISM.exe /Cleanup-Mountpoints

Cleanup does not commit image changes. Confirm that no recoverable mount contains work that still needs to be saved.

Troubleshooting

DISM Reports That Source Files Could Not Be Found

  • Verify the ISO’s Windows release, architecture, language, edition, and servicing level.
  • Confirm whether the media contains install.wim or install.esd.
  • Use /Get-WimInfo and select the correct image index.
  • Remove /LimitAccess if policy permits Windows Update to supply missing repair content.

DISM Reports a Pending Restart

Finish installing updates and restart Windows before retrying. Do not delete servicing registry keys or pending-operation files to bypass the requirement.

Review the Logs

Display recent DISM errors in PowerShell:

Select-String -Path "$env:windir\Logs\DISM\dism.log" -Pattern 'Error','Failed' | Select-Object -Last 50

Extract recent SFC entries from the CBS log:

findstr.exe /c:"[SR]" %windir%\Logs\CBS\CBS.log > "%USERPROFILE%\Desktop\SFC-details.txt"

Review the surrounding log context before acting on an isolated error line. If repairs repeatedly fail with matching media, check storage health, memory stability, update history, and the exact error code before attempting more invasive recovery.

comments powered by Disqus