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  –

Comments

3 responses to “Add or Remove a driver from a Wim Image using DISM”

  1. Marius - Roma - Italy Avatar
    Marius – Roma – Italy

    I see that you have an in-depth experience with Windows 7 customization tools.
    I see as well thet there are lots of different tools and options, so I am confused.
    Let me ask for advice to solve a problem: I need to install Windows 7 on a PC with not standard HW. During setup with standard Microsoft DVD I get a blue screen related to the (custom) video card.
    I have the right video card drivers.
    What is the best way (and simplest) way to provide the right drivers during setup?
    Based on what I understand from your site I created a bootable installtation pendrive, edited install.wim using DISM to add my drivers, replaced install.wim on my pendrive, booted my custom PC with winPE and started setup from the pendrive.
    How can I tell setup to use the video card drivers I added?
    Am I performing the right steps?
    Regards from Italy
    Marius

  2. msigeek Avatar
    msigeek

    Hi Marius, Thanks for your comments!

    Do check if you have an setup file for these drivers (.inf files). If yes, follow the above steps as mentioned. Save and Commit the Wim Image., and then test the image.

    I recommend, you do the test before trying out the deployment. The steps which you are following looks correct. Just ensure that the drivers are added to your image. Commit the Wim and then install with it.

    Let me know, how it goes!

  3. Tom Floor Avatar

    This does not appear to work on Vista images build on Vista SP1, although the image has been upgraded to SP2. When I try to add drivers, this is what happens:
    C:Program FilesWindows AIKToolsPETools>dism /image:C:MountDir /add-driver /driver:”C:HPSwSetupSP52567Graphics2342hp32.inf”
    Deployment Image Servicing and Management toolVersion: 6.1.7600.16385
    Error: 50
    The command specified is unknown or not supported when running DISM.exe againsta Windows Vista with Service Pack 1 or a Windows Server 2008 target image.For more information, see the Help documentation available in the Windows Automated Installation Kit (Windows-AIK) or the Windows OEM Preinstallation Kit (OPK).
    The DISM log file can be found at C:WINDOWSLogsDISMdism.log
    C:Program FilesWindows AIKToolsPETools>

    And then DISM.log shows where it goes wrong:
    2011-08-18 14:04:43, Info                  DISM   DISM.EXE: The target image version is: 6.0.6002.18005.2011-08-18 14:04:43, Info                  DISM   DISM.EXE: The target image is downlevel and considered supported. Looking for PkgMgr.exe.2011-08-18 14:04:43, Info                  DISM   DISM.EXE: Executing DISM against a downlevel image. Calling C:MountDirWindowsWinSxSx86_microsoft-windows-servicingstack_31bf3856ad364e35_6.0.6002.18005_none_0b4ada54c46c45b0pkgmgr.exe2011-08-18 14:04:43, Info                  DISM   DISM Provider Store: PID=3600 Getting Provider Compatibility Manager – CDISMProviderStore::GetProvider2011-08-18 14:04:43, Info                  DISM   DISM Provider Store: PID=3600 Provider has previously been initialized.  Returning the existing instance. – CDISMProviderStore::Internal_GetProvider2011-08-18 14:04:43, Info                  DISM   Compatibility Manager: PID=3600 Processing the top level command token(add-driver). – CCbsCliParser::Private_ValidateCmdLine2011-08-18 14:04:43, Info                  DISM   Compatibility Manager: PID=3600  Unknown top level command token add-driver – CCbsCliParser::Private_ValidateCmdLine2011-08-18 14:04:43, Info                  DISM   Compatibility Manager: PID=3600 This command is unsupported for a downlevel image. – CCompatManager::CompatExecuteCmdLine2011-08-18 14:04:43, Info                  DISM   DISM.EXE: Image session has been closed. Reboot required=no.

    Are there any solutions for this? Can’t find any on technet, only people who have got the same problem.

Leave a Reply

Your email address will not be published. Required fields are marked *