Share via


Add Device Drivers to an Offline Windows Image

You can use Package Manager (Pkgmgr.exe) to install one or more device drivers to an offline Windows image. With Pkgmgr, boot-critical device drivers are added to Windows before installation.

When you use Package Manager to install a device driver to an offline image, the device driver is added to the driver store. The driver store is a location on the computer that contains all the drivers for that computer. When Plug and Play runs, detected devices are matched with device drivers in the driver store. The driver store replaces Drivers.cab in Microsoft Windows XP and earlier operating systems.

Boot-critical drivers are reflected on the system. Driver reflection is the process of installing a driver on a computer that might or might not have a device for that driver. Typically, this involves copying the driver files to a destination location and creating the service.

If you need drivers for Windows PE to see the local hard disk drive or a network, the WindowsPE configuration pass must be used to add drivers to the Windows PE driver store and to reflect boot-critical drivers required by Windows PE. For more information, see Add Device Drivers During Windows Setup.

It is important to note that 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.

To add drivers to an offline Windows image

  1. Locate the device driver .inf files that you intend to install on your Windows image.

  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 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 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 equals to 1 and the value of Key for the second path equals to 2.

  1. Save the answer file and exit Windows SIM. The answer file must be similar to the following sample.

    <?xml version="1.0" ?>
    <unattend xmlns="urn:schemas-microsoft-com:asm.v3" xmlns:wcm="https://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>
    
  2. Mount the Windows image that you intend to install the drivers to by using ImageX. For example:

    imagex /mountrw C:\windows_distribution\sources\install.wim 1 C:\wim_mount
    

    The first Windows image in the Install.wim file is mounted to C:\wim_mount. For more information, see ImageX Command-Line Options.

  3. Enable logging of specific device driver injection actions in a separate log file. Edit the following registry key on the computer on which you are running Package Manager:
    Path: HKLM\Software\Microsoft\Windows\CurrentVersion\Device Installer
    Key: DebugPkgMgr
    Type: REG_DWORD
    Value: 0x01
    This will create a Drivers.log file during the driver package injection. This log file will log all actions of the driver injection process.

  4. Use Package Manager to apply the unattended installation answer file to the mounted Windows image. Specify a location for the log file to create. For example,

    pkgmgr /o:"C:\wim_mount\;C:\wim_mount\Windows" /n:"C:\unattend.xml" /l:"C:\pkgmgrlogs\logfile.txt"
    

    For more information about using Package Manager, see Package Manager Command-Line Options.
    The .inf files referenced in the path in the answer file are added to the Windows image. A log file is created in the directory C:\Pkgmgrlogs\. Driver log files are created in the directory that PkgMgr runs from. You can open the Drivers.log file and review the Package Manager driver injection actions.

  5. Review the contents of the %WINDIR%\Inf\ directory in the mounted Windows image to ensure that the .inf files were installed. Drivers added to the Windows image are named oem*.inf. This is to ensure 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.

  6. Unmount the .wim file and commit the changes. For example,

    imagex /unmount /commit C:\wim_mount
    

The Windows image is ready to be deployed.

See Also

Concepts

Manage Device Drivers for Windows
Add Device Drivers During Windows Setup