DISM is a command-line tool by Microsoft used to mount, service, capture, and deploy Windows images (.wim, .vhd, .vhdx). It is essential in Windows deployment and maintenance processes.
.wim filesC:\Windows\System32\Sysprep\Sysprep.exe /generalize /oobe /shutdown
/generalize
Removes system-specific data such as:
/oobe
Prepares the system for the Out-of-Box Experience (OOBE), which runs when the computer is started by a new user.
/shutdown
Automatically shuts down the system after Sysprep completes its tasks.
Note: Do not boot into Windows again after Sysprep before capturing the image.
DISM /Capture-Image /ImageFile:D:\CustomInstall.wim /CaptureDir:C:\ /Name:"Windows 10 Pro Custom"
/ImageFile
Path to save the captured .wim image file.
Example: D:\CustomImage.wim
/CaptureDir
Specifies the root directory of the Windows installation to capture (usually the OS drive).
Example: C:\
/Name
A friendly name assigned to the captured image.
Example: "Windows 10 Pro Custom"
DISM /Mount-WIM /WimFile:D:\CustomInstall.wim /Index:1 /MountDir:D:\Mount
DISM /Image:D:\Mount /Add-Driver /Driver:D:\Drivers /Recurse
DISM /Image:D:\Mount /Enable-Feature /FeatureName:NetFx3
DISM /Unmount-WIM /MountDir:D:\Mount /Commit
Unmounts and saves the changes
Boot into WinPE or use PXE/WDS and run:
DISM /Apply-Image /ImageFile:D:\CustomInstall.wim /Index:1 /ApplyDir:C:\
/ApplyDir: is the drive where Windows will be installed
bcdboot C:\Windows
Initializes boot files for the new Windows installation
Check and Repair System Image Health
DISM /Online /Cleanup-Image /CheckHealth
DISM /Online /Cleanup-Image /ScanHealth
DISM /Online /Cleanup-Image /RestoreHealth
Used on the currently running system (/Online)
Use /Online for servicing the currently running OS
Use /Image: path (under <>) for offline servicing of mounted images
Always test a captured image before deploying at scale