Add or Remove a driver from a Wim Image using DISM

You can offline service an image using DISM and add drivers to the mounted ones. You will need to download driver packages from OEM’s and ISV’s. These packages need to be INF-based packages (.exe or .msi driver installation is not available offline).

You can then use the DISM add-driver command to add the INF-based driver to the image. If you want to install all drivers in a directory, add the /Recurse switch. To validate that the package was installed, use the Get-Drivers command to query the image (this defaults to listing third party drivers only, which can be over-ridden by using the /All option). Use /ForceUnsigned to add unsigned drivers to X64-based images.

To do these operations, you should mount the Wim image first. If you arent aware on the steps, then do check this article!

DISM image servicing – VHD Support

  • Same servicing support as for WIM images. (Just replace the /MountDir folder with the virtual harddisk Drive Letter!)
  • Must use separate tools like diskpart to attach the VHD image for servicing
  • All updates are committed to the VHD image right after completion of the servicing operation

In this example, let me add a third party hp driver to a wim image which is already mounted. First, lets list out the drivers which are already a part of this Wim image. using the command dism /image:”<imagemountdir> /get-drivers

DISM /get-Drivers

Now I am adding a third party driver(hp) using the switch /add-driver. The command would look like, dism /image:<imagemountdir> /add-driver /driver:<pathtotheinffile>

DISM /Add-driver

When you list of the drivers which are present on the Wim Image,  you will see a new oem1.inf has been added to the image. This is the hpstape.inf driver which we just added. The tool automatically enumarates the number of the oem file and creates a published name. Thats the reason, you see a oem1.inf getting created. Now, when you add a new driver again, it would be oem2.inf.. and so on..! –

This phenomenan is very important, as hardcoding this oem file number will put the machine in a un-safe state., and un-installing them will cause a chaos!

DISM /get-drivers

If you want to remove a driver from the Wim image, you can just run the dism tool with the /remove-driver switches, dism /image:<imagemountdir> /remove-driver /driver:<publishedname>

Dism /Remove-driver

Driver Servicing Commands:

/Remove-Driver –  Removes driver packages from an offline image.
/Add-Driver – Adds driver packages to an offline image.
/Get-DriverInfo – Displays information about a specific driver in an offline image or a running operating system
/Get-Drivers  – Displays information about all drivers in  an offline image or a running operating system.

You would also be interested in reading this  –