Inject or Delete Drivers from WIM

  1. At an elevated command prompt, type:
    Dism /Get-ImageInfo /ImageFile:C:\test\images\install.wim
    

     

    An Index or Name value is required for most operations that specify a WIM file (which can be obtained from Get-ImageInfo). For a VHD file, you must specify /Index:1. The Name from the output will be added to the below command…in the Windows Version Type. You cannot use /Index and /Name at the same time.

  2. Mount the offline Windows image. For example, type:
    Dism /Mount-Image /ImageFile:C:\test\images\install.wim /Name:"Windows Version Type" /MountDir:C:\test\offline
    
  3. Add a specific driver to the image. For example, type:
    Dism /Image:C:\test\offline /Add-Driver /Driver:C:\drivers\mydriver.inf
    


    NOTE: You’ll use the /Recurse option for most driver packages
    Multiple drivers can be added on one command line if you specify a folder instead of an .inf file. To install all of the drivers in a folder and all its subfolders use the /recurse option. For example,

    Dism /Image:C:\test\offline /Add-Driver /Driver:c:\drivers /Recurse
    

    To install an unsigned driver, use /ForceUnsigned to override the requirement that drivers installed on X64-based computers must have a digital signature. For example,

    Dism /Image:C:\test\offline /Add-Driver /Driver:C:\drivers\mydriver.inf /ForceUnsigned
    
  4. Review the list of third-party driver (.inf) files in the Windows image. Drivers added to the Windows image are named Oem*.inf. This is to guarantee unique naming for new drivers added to the computer. For example, the files MyDriver1.inf and MyDriver2.inf are renamed Oem0.inf and Oem1.inf. For example, type:
    Dism /Image:C:\test\offline /Get-Drivers 
    
    
  5. Commit the changes and unmount the image. For example, type:
    Dism /Unmount-Image /MountDir:C:\test\offline /Commit
    
  1. At an elevated command prompt, locate the Windows ADK servicing folder, and type the following command to retrieve the name or index number for the image that you want to modify.
    Dism /Get-ImageInfo /ImageFile:C:\test\images\install.wim
    

    An index or name value is required for most operations that specify a WIM file. For a VHD file, you must specify /Index:1.

  2. Mount the offline Windows image. For example, type:
    Dism /Mount-Image /ImageFile:C:\test\images\install.wim /Name:"Windows 7 HomeBasic" /MountDir:C:\test\offline
    
  3. Remove a specific driver from the image. Multiple drivers can be removed on one command line. For example, type:
    Dism /Image:C:\test\offline /Remove-Driver /Driver:OEM1.inf /Driver:OEM2.inf
    
    Warning
    Removing a boot-critical driver package can make the offline Windows image unbootable. For more information, see DISM Driver Servicing Command-Line Options.
  4. Commit the changes and unmount the image. For example, type:
    Dism /Unmount-Image /MountDir:C:\test\offline /Commit
    

 


To add drivers to an offline Windows image by using an unattended answer file

  1. Locate the device driver .inf files that you intend to install on the Windows image.
    Note
    All drivers in the directory and subdirectories that are referenced in the answer file are added to the image. You should manage the answer file and these directories carefully to address concerns about increasing the size of the image with unnecessary driver packages.
  2. Use Windows System Image Manager (Windows SIM) to create an answer file that contains the paths to the device drivers that you intend to install.
  3. Add the Microsoft-Windows-PnpCustomizationsNonWinPE component to your answer file in the offlineServicing configuration pass.
  4. Expand the Microsoft-Windows-PnpCustomizationsNonWinPE node in the answer file. Right-click DevicePaths, and then select Insert New PathAndCredentials.A new PathAndCredentials list item appears.
  5. For each location that you intend to access, add a separate PathAndCredentials list item.
  6. In the Microsoft-Windows-PnpCustomizationsNonWinPE component, specify the path to the device driver and the credentials that are used to access the file, if the file is on a network share.
    Note
    You can include multiple device driver paths by adding multiple PathAndCredentials list items. If you add multiple list items, you must increment the value of Key for each path. For example, you can add two separate driver paths where the value of Key for the first path is equal to 1 and the value of Key for the second path is equal to 2.
  7. Save the answer file and exit Windows SIM. The answer file must resemble the following sample.
    <?xml version="1.0" ?><unattend xmlns="urn:schemas-microsoft-com:asm.v3" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State">
      <settings pass="offlineServicing">
         <component name="Microsoft-Windows-PnpCustomizationsNonWinPE" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
            <DriverPaths>
               <PathAndCredentials wcm:keyValue="1">
                  <Path>\\networkshare\share\drivers</Path>
                  <Credentials>
                     <Domain>Fabrikam</Domain>
                     <Username>MyUserName</Username>
                     <Password>MyPassword</Password>
                  </Credentials>
               </PathAndCredentials>
            </DriverPaths>
         </component>
      </settings>
    </unattend>
    
  8. Mount the Windows image that you intend to install the drivers to by using DISM. For example, type:
    Dism /Mount-Image /ImageFile:C:\test\images\install.wim /Index:1 /MountDir:C:\test\offline
    

    An index or name value is required for most operations that specify a WIM file. For a VHD file, you must specify /Index:1.

  9. Use DISM to apply the answer file to the mounted Windows image. For example, type:
    DISM /Image:C:\test\offline /Apply-Unattend:C:\test\answerfiles\myunattend.xml
    

    For more information about how to apply an answer file, see DISM Unattended Servicing Command-Line Options.

    The .inf files referenced in the path in the answer file are added to the Windows image.

  10. Review the list of third-party driver (.inf) files in the Windows image. Drivers added to the Windows image are named Oem*.inf. This is to guarantee that all new drivers that are added to the computer are uniquely named. For example, the files MyDriver1.inf and MyDriver2.inf are renamed Oem0.inf and Oem1.inf.For example, type:
    Dism /Image:C:\test\offline /Get-Drivers 
    
    
  11. Unmount the .wim file and commit the changes. For example, type:
    Dism /Unmount-Image /MountDir:C:\test\offline /Commit