Using DISM to Add Drivers / Packages / Install Roles and Features in a .wim file

The following reference folders that contain the relevent drivers/packages. Ensure you have the driver/package in the right location e.g. .\drivers

### DISM - Deployment Image Servicing and Management Command-line Utility ###

## Desktop Experience & Server Core ##

# display help
dism /?

# view images within a .wim
dism /get-imageinfo /imagefile:.\images\install.wim

# mount server core datacenter image
dism /mount-image /imagefile:.\images\install.wim /index:3 /mountdir:.\mount

# add drivers (.inf)
dism /image:.\mount /get-drivers
dism /image:.\mount /add-driver /driver:.\drivers
dism /image:.\mount /remove-driver /driver:.\drivers\iaStorAC.inf

# add patches, hotfixes, and updates (.msu or .cab)
dism /image:.\mount /get-packages
dism /image:.\mount /add-package /packagepath:.\updates
dism /image:.\mount /remove-package /packagepath:.\updates\windows10.0-kb3150513.msu

# install roles and features
dism /image:.\mount /get-features
dism /image:.\mount /get-featureinfo /featurename:web-server
dism /image:.\mount /enable-feature /featurename:web-server /all
dism /image:.\mount /disable-feature /featurename:web-server

# dismount and commit all changes
dism /unmount-image /mountdir:.\mount /commit

## Nano Server ##

# view nano server images
dism /get-imageinfo /imagefile:.\images\nanoserver.wim

# mount nano server datacenter image
dism /mount-image /imagefile:.\images\nanoserver.wim /index:2 /mountdir:.\mount

# add nano server package
dism /image:.\mount /add-package /package:d:\nanoserver\packages\

# dismount and commit all changes
dism /unmount-image /mountdir:.\mount /discard


Windows wont boot up - How to troubleshoot

Tools for boot up issues:

For any error messages about boot problems or the MBR try the following. If you suspect this is a disk error, jump straight to ChkDsk.

BootRec.exe /fixmbr

you can also substitue the /fixmbr with thes commands:

/FixBoot. Writes a boot sector onto the system partition to start Windows

/ScanOs. Scans all disks for Windows installations and displays them to you. 

/RebuildBcd. Scans all disks for Windows installations and prompts you to pick the ones you want to add to the BCD.

If this doesn't work try Booting from "Last Known Good Configuration" from the boot menu. (Tap F8 while OS is booting).
If you can't get to last known good config, you may need to run this from CMD.

BCDEdit /SET "{bootmgr}" displaybootmenu yes

If this doesn't work try the startup repair from the repair disk.

If the doesn't work, try an SFC scan.

If the System is Windows 8 on wards, try DISM.

If that doesn't work run a ChkDsk -f -r from command prompt.

One of these tools should yeild some kind of result unless there is a massive OS corruption or hardware failure. 

Injecting Drivers into an install.wim using DISM

When using Windows Deployment Server to roll out a new OS, if the driver of the NIC is not in the standard install.wim the installation will fail with this error.

"WdsClient: An error occurred while obtaining an IP address from DHCP server. Please check to ensure that there is an operational DHCP server on this network segment".

WDS comes with the option to add Drivers to the WIM through the GUI but seems to fail for all 57 variants of the drivers.

Here are the steps to setup for and inject the drivers into the boot.wim file with DISM.


1.       Create the following folders on the root of the C drive:


2.       Copy the drivers you wish to inject into the C:\Mount\Drivers folder

3.       NB; the drivers need to be the INF files and not the EXE’s..

      then copy your original boot.wim to the C:\Mount folder.


1.       Open the Deployment and Imaging Tools Environment command prompt, from the Windows Kits start menu folder, as Administrator.

2.       Navigate to "C:\Mount".

3.       Use the following DISM commands to mount the Boot.wim:

DISM /Mount-Wim /WimFile:C:\Mount\boot.wim /Index:2 /MountDir:C:\Mount\BootWIM

4.       Use the following DISM command to add the driver:

DISM /Image:C:\Mount\BootWIM /Add-Driver /Driver:C:\Mount\Drivers /recurse

5.       Use the following DISM command to unmount the Boot.wim:

DISM /Unmount-Wim /MountDir:C:\Mount\BootWIM /Commit

Once this is done you can add the amended boot.wim to your Boot Images in WDS

Use DISM to repair corrupt operating systems

DISM can be used (like SFC /Scannow) to repair system os files. DISM is better, because if uses source files you specify to repair the corruptions. The advantage of this is apparent when a machine might be powered off during windows updates and the source files get corrupted. SFC might not be able to repair the files but with a windows ISO and DISM you can repair the OS without issue.

1. Burn your Windows ISO to a USB/DVD
2. Boot your machine up using the USB/DVD
3. SHIFT + F10 to enter Command prompt
4. Identify each drive and it letter connected.
list disk
select disk (X)
detail disk
5. Once you know which letter your USB/DVD media has you need to find the Index of your OS.
DISM /get-wiminfo /wimfile:E:\Sources\install.wim

6. Next we start the clean image process. If you cannot boot up windows, this command will differ. To run this command while in CMD from a recovery disk use the /Image parameter:
Dism.exe /Image:C:\ /Cleanup-Image /StartComponentCleanup
To run this while the OS is booted run it like this:
Dism.exe /online /Cleanup-Image /StartComponentCleanup

7. As above the following command depends on if the OS is running or not:
From WinPE
DISM /Image:C:\ /Cleanup-Image /RestoreHealth /Source:WIM:E:\Sources\Install.wim:4
From OS
DISM /online /Cleanup-Image /RestoreHealth /Source:WIM:E:\Sources\Install.wim:4
(Where E= your ISO drive letter and 4 = your OS edition)

This should clean the image.

Error: sfc /scannow there is a system repair pending

To run an SFC (System File Checker) scan, open CMD and type SFC /Scannow. 
If you OD won't boot jump to (2).
If when trying to run an sfc /SCANNOW command it fails saying that a system repair or reboot is pending try this:

1. Boot to recovery disk and go to the command prompt
2. SFC /SCANNOW /OFFBOOTDIR=C:\ /OFFWINDIR=C:\Windows - where offbootdir is the system partition and winbootdir is the primary partition.

If this fails, try this:
dism.exe /image:C:\ /cleanup-image /revertpendingactions

(Note: Step 2 is the known solution for this error - but I have also seen /revertpendingtransactions alot but it has never worked for me.)