DISM - CMD
Overview
DISM (Deployment Image Servicing and Management) is a command-line tool used for servicing and managing Windows images, including those used for Windows PE, Windows Recovery Environment, and Windows Setup. DISM can also be used to update, add, or remove Windows features and drivers in an offline image. It is a vital tool for administrators to manage and prepare Windows images in various phases of deployment.
Syntax
The basic syntax for using DISM is:
DISM.exe /Online /Image:Path /SomeOption
Here /Online
targets the running OS, while /Image
specifies the path to an offline image. /SomeOption
represents various operations you can perform with DISM.
General Syntax:
DISM /Online /Option [additional parameters]
For Managing Offline Images:
DISM /Image:C:\test\offline /Option [additional parameters]
Options/Flags
DISM offers a vast array of options, which can be used to manage and maintain Windows images:
- /Online – Targets the running OS.
- /Image – Specifies the path to the root directory of an offline image.
- /Cleanup-Image – Provides options to cleanup and recover the image.
- /CheckHealth – Check whether any corruption has been detected.
- /ScanHealth – Perform an advanced scan to check for setup problems.
- /RestoreHealth – Fix any detected corruption using Windows Update.
- /Add-Package – Adds packages to the image.
- /PackagePath – Specifies the path to the package.
- /Add-Capability – Adds capabilities like .NET Framework or other optional features.
- /Remove-Capability – Remove specified capabilities from the image.
- /Enable-Feature – Enables specific features.
- /Disable-Feature – Disables specified features within the image.
- /Get-Features – Lists all features in the image.
Examples
Scan an Online Image for Corruption
DISM /Online /Cleanup-Image /CheckHealth
Add a Package to an Offline Image
DISM /Image:C:\offline /Add-Package /PackagePath:C:\packages\MyPackage.cab
Enable a Feature in an Online Image
DISM /Online /Enable-Feature /FeatureName:TelnetClient
Remove a Capability from an Online Image
DISM /Online /Remove-Capability /CapabilityName:Tools.Graphics.DirectX~~~~0.0.1.0
Common Issues
- Access Denied: Run the command prompt as an administrator to avoid permission issues.
- Corrupted Image Repair Failure: Sometimes, DISM cannot repair a corrupted image if the sources for repair are also corrupted. Ensure that your recovery environment is intact.
- Slow Operation: DISM can be slow if the system is running other intensive processes. Consider running DISM during low activity periods or ensure adequate system resources.
Integration
DISM can be used in scripts with other commands like sfc /scannow for a comprehensive system recovery strategy:
sfc /scannow
DISM /Online /Cleanup-Image /RestoreHealth
Related Commands
- sfc (System File Checker) – Scans integrity of all protected system files and replaces incorrect versions with correct Microsoft versions.
- bcdedit – Used for managing boot configuration data, helpful in preparing environments for image deployment.
Further information can be found on the official Microsoft DISM documentation.
This comprehensive guide serves as a starting point for using DISM effectively in various scenarios tailored for system administrators and IT professionals.