DISM Syntax Cheat Sheet: Online & Offline Commands
This cheat sheet covers DISM (Deployment Imaging Service and Management) commands for Windows, showing the exact syntax for both online (running system) and offline (mounted image) servicing. You’ll get the core commands, common options, and real examples for repairing system images, managing drivers, and handling Windows feature packages.
What DISM Is and When You Need It
DISM is a command-line tool built into Windows (since Windows 8/Server 2012) that services Windows images (.wim, .vhd, .vhdx) and prepares the Windows Recovery Environment. It replaces older tools like PEimg and Intlcfg. You use DISM when Windows Update fails, when system files are corrupted (often paired with SFC), when you need to add or remove drivers from an offline image, or when you want to enable or disable Windows features without reinstalling.
Basic Syntax Structure
Every DISM command follows this pattern:
DISM /Command /Option:Value
Commands are case-insensitive, but paths and image names are not. You must run DISM from an elevated Command Prompt (Run as administrator). For offline servicing, you first mount an image to a folder using /Mount-Image, then run commands against that folder with /Image:C:\mount.
Online Commands (Running System)
Online commands target the currently running Windows installation. The most common ones are:
- Check health:
DISM /Online /Cleanup-Image /CheckHealth— quick scan, no repairs, reports if corruption is detected. - Scan health:
DISM /Online /Cleanup-Image /ScanHealth— full scan, can take 10-20 minutes, reports whether corruption is present. - Restore health:
DISM /Online /Cleanup-Image /RestoreHealth— repairs corruption using Windows Update. Add/Source:repair\install.wimto use a local source instead of Windows Update. - List features:
DISM /Online /Get-Features— shows all Windows features with their state (Enabled/Disabled). - Enable feature:
DISM /Online /Enable-Feature /FeatureName:NetFx3 /All— enables .NET 3.5 (the /All switch also enables parent features). - Disable feature:
DISM /Online /Disable-Feature /FeatureName:WindowsMediaPlayer - Get current edition:
DISM /Online /Get-CurrentEdition - Get packages:
DISM /Online /Get-Packages— lists all installed packages.
Offline Commands (Mounted Images)
Offline servicing requires an image file. Here’s the workflow:
- Mount the image:
DISM /Mount-Image /ImageFile:C:\sources\install.wim /Index:1 /MountDir:C:\mount - Service the image: run any DISM command with
/Image:C:\mountinstead of/Online. For example:DISM /Image:C:\mount /Get-FeaturesorDISM /Image:C:\mount /Add-Driver /Driver:C:\drivers\driver.inf - Commit changes:
DISM /Unmount-Image /MountDir:C:\mount /Commit— saves changes and unmounts. Use/Discardinstead of/Committo discard changes.
You can also add a driver to an offline image with /Add-Driver (note: for Windows 10/11, use /Add-Driver /Driver:C:\drivers to add all .inf files in a folder). Remove a driver with /Remove-Driver /Driver:C:\drivers\driver.inf.
Common Options and Switches
Several options appear across commands:
/Source— specifies a repair source (e.g.,/Source:C:\Windows\WinSxSor a mounted install.wim). Use with/RestoreHealth./LimitAccess— prevents DISM from contacting Windows Update; forces it to use only the /Source./LogPath— sets a custom log file (default is%windir%\Logs\DISM\dism.log)./English— outputs logs in English regardless of system language./NoRestart— suppresses automatic restart after a feature change./Quiet— suppresses on-screen output (but still logs).
Real-World Examples
Here are three typical scenarios with full commands:
Repair a corrupted system (online):
DISM /Online /Cleanup-Image /RestoreHealth /Source:C:\repaired\install.wim /LimitAccess
This repairs the running system using a local install.wim, without contacting Windows Update.
Add a language pack to an offline image:
DISM /Mount-Image /ImageFile:C:\iso\install.wim /Index:1 /MountDir:C:\mount DISM /Image:C:\mount /Add-Package /PackagePath:C:\lang\fr-fr.cab DISM /Unmount-Image /MountDir:C:\mount /Commit
List all drivers in an offline image:
DISM /Image:C:\mount /Get-Drivers
Common Mistakes and Troubleshooting
- Forgetting to run as administrator — DISM will fail with error 740 or simply not execute. Right-click Command Prompt and select “Run as administrator”.
- Wrong image index — install.wim often contains multiple editions. Use
DISM /Get-WimInfo /WimFile:C:\sources\install.wimto list indexes first. - Mount directory not empty — the mount folder must be empty before mounting.
- Unmount without commit — if you unmount with /Discard, all changes are lost. Double-check before running.
- Error 87 — invalid command or option; check spelling and syntax exactly.
- Error 2 — file not found; verify paths and that the image is actually mounted.
Frequently Asked Questions
What is the difference between DISM and SFC?
SFC (System File Checker) scans and repairs protected system files on the running system. DISM can repair the system image itself, which is often needed when SFC fails. The recommended order is: run DISM /RestoreHealth first, then run SFC /scannow.
Can DISM fix all Windows corruption?
No. DISM repairs components of the Windows image, but it cannot fix hardware issues, disk errors (run chkdsk instead), or corruption in files outside the Windows image. If DISM fails, you may need a repair install or a fresh installation.
How long does DISM /ScanHealth take?
It varies by system speed and disk health; typically 10-20 minutes. RestoreHealth can take longer because it downloads and applies repairs. Do not interrupt it — closing the window can leave the system in a partially repaired state.
Can I run DISM on Windows 7?
Yes, but with limitations. DISM is available in Windows 7 SP1, but some commands like /Cleanup-Image are not available. For Windows 7, you’d use the older /Online /Cleanup-Image /RestoreHealth (which works) but /Get-Features may not work as expected.
What does the /All switch do in Enable-Feature?
It enables all parent features required by the specified feature. For example, enabling NetFx3 with /All also enables the .NET 3.5 framework dependencies. Without it, the command may fail if a parent feature is disabled.
Is it safe to delete the DISM log file?
Yes, the log file is just a text record. You can delete it, but DISM will recreate it on the next run. Keeping it helps troubleshooting if errors recur.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.