共用方式為


Add Device Drivers During Windows Setup

You can install additional device drivers during Windows Setup by creating an answer file. In this answer file, you can specify the paths to device drivers on a network share (or a local path) by adding the Microsoft-Windows-PnpCustomizationWinPE or Microsoft-Windows-PnpCustomizationNonWinPE components and specifying the configuration passes in which you intend to install them. You can install device drivers in the windowsPE, offlineServicing, auditUser or auditSystem configuration passes.

By adding device drivers during the windowsPE or offlineServicing configuration passes, you can add out-of-box device drivers to the Windows image before the computer starts. This method can also be used to add boot-critical device drivers to a Windows image.

If you need boot-critical drivers for Windows PE, use the windowsPE configuration pass to reflect the drivers before the Windows PE image is booted. The difference between adding boot-critical drivers during the WindowsPE configuration and the OfflineServicing configuration pass is that, during the WindowsPE configuration pass, boot-critical drivers are reflected for use by Windows PE and other drivers are staged to the Windows PE driver store. Then, during the offlineServicing configuration pass, the drivers in the Windows PE driver store are staged to the driver store on the Windows image.

When you add additional out-of-box drivers during the auditUser or auditSystem configuration passes, you must use Sysprep to boot to audit mode. This method can be helpful if you want to maintain a simple Windows image, and then add only the drivers that are required for a specific hardware configuration.

In some manufacturing and corporate environments, a single, large share of drivers is maintained. When you use an unattended answer file or Package Manager to install these drivers, the drivers are imported into the driver store. The driver store is a location on the computer that contains all the drivers for that computer. This can create performance and disk space problems if you maintain a single large share of drivers.

Driver shares should be carefully managed so that only the required drivers are added to the Windows driver store on each computer. However, if this is not practical, you can add non-boot critical drivers online by calling the Driver Package Installer (DPInst) version 2.1 in the auditUser configuration pass of an unattended Setup. DPInst can be used to selectively install drivers only if the hardware is present or if the driver package is a better match for the device.

DPInst is a component of Driver Install Frameworks (DIFx) version 2.1. It is a redistributable tool that is available in the Windows Driver Kit (WDK). For more information about the WDK, see How to Participate in the WDK and WLK Program on Microsoft Connect. It is important to use DPInst version 2.1 available only in the Windows Vista WDK.  This includes improvements over version 2.01 specific to Windows Vista.

The following table describes the different configuration passes and how they are used to add device drivers during Windows Setup.

Configuration Pass Description Adding Device Drivers

windowsPE

This configuration pass is used to configure settings that are specific to Windows Preinstallation Environment (Windows PE).If you need drivers for Windows PE to see the local hard disk drive or a network, this configuration pass must be used to add the necessary drivers to the Windows PE driver store.

The windowsPE confiiguration pass also configures settings that apply to installation. This means that drivers in the Windows PE driver store are also reflected into the offline Windows image or copied to the Windows image driver store during offline servicing.

For more information, see the windowsPE.

Add the Microsoft-Windows-PnpCustomizationsWinPE component to your answer file in the windowsPE configuration pass, and then add device driver paths to the Microsoft-Windows-PnpCustomizationsWinPE component.

Boot to Windows PE, run Windows Setup and specify the name of the answer file.

This method initiates Windows PE and processes Windows PE settings from the answer file. First, Windows PE drivers are staged in the driver store in RAM, and boot-critical drivers that are required for Windows PE to access the local disk and network are reflected into Windows PE. Other Windows PE customizations that are specified in the answer file are also processed.

Second, during Windows Setup, the Windows image is applied and boot-critical drivers are reflected on the Windows image before that image is installed. Other drivers that were added to the Windows PE driver store are staged to the Windows image driver store. When the offlineServicing pass is processed any drivers specified in the driver path are also added to the Windows image driver store.

offlineServicing

This configuration pass runs during Windows Setup to applies unattended Setup settings to an offline Windows image.

Add the Microsoft-Windows-PnpCustomizationNonWinPE component to your answer file in the offlineServicing configuration pass, and then add device driver paths to the Microsoft-Windows-PnpCustomizationNonWinPE component.

Run Windows Setup and specify the name of the answer file.

This method reflects boot-critical drivers to a Windows image before that image is installed and processes out-of-box device drivers during Windows Setup, adding the drivers to the Windows image driver store.

auditUser

This configuration pass processes unattended Setup settings after a user logs on to the computer. The auditUser pass runs only if you boot to audit mode.

auditUser is used to execute RunSynchronous or RunAsynchronous commands that run scripts, applications, or other executables.

When Windows boots to audit mode, the auditUser settings for unattended Windows Setup are processed and commands are executed.

Add a custom command to an answer file in the auditUser configuration pass.

In the custom command start the Driver Package Installer (DPInst) to add non-boot critical drivers.

DPInst is a component of Driver Install Frameworks (DIFx) version 2.1. It is available in the Windows Driver Kit (WDK). For more information, see How to Participate in the WDK and WLK Program on Microsoft Connect.

auditSystem

Processes unattended Setup settings while Windows is running in system context, before a user logs on to the computer in audit mode. The auditSystem pass runs only if you boot to audit mode

Add the Microsoft-Windows-PnpCustomizationNonWinPE component to your answer file in the auditSystem configuration pass, and then add device driver paths to the Microsoft-Windows-PnpCustomizationNonWinPE component.

When you run Windows Setup the answer file is cached. When you use sysprep to run audit mode, the settings in the answer file are applied.

For more information about these and other configuration passes, see Windows Setup Configuration Passes.

Adding a device driver during Windows PE

To add device drivers during WindowsPE, create an answer file and specify the paths to device drivers in the Microsoft-Windows-PnpCustomizationsWinPE component before you run Windows setup.

To add a device driver during Windows PE

  1. 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.

  2. Add the Microsoft-Windows-PnpCustomizationsWinPE component to your answer file in the windowsPE configuration pass.

  3. Expand the Microsoft-Windows-PnpCustomizationsWinPE node in the answer file. Right-click DevicePaths and select Insert New PathAndCredentials.
    A new PathAndCredentials list item appears.

  4. For each location that you access, add a separate PathAndCredentials list item.

  5. In the Microsoft-Windows-PnpCustomizationsWinPE 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, if you add two separate driver paths, then the first path uses the Key value of 1, and the second path uses the Key value of 2.

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

    <?xml version="1.0" encoding="utf-8" ?> 
    <unattend xmlns="urn:schemas-microsoft-com:unattend">
       <settings pass="windowsPE">
          <component name="Microsoft-Windows-PnpCustomizationsWinPE" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="https://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
             <DriverPaths>
                <PathAndCredentials wcm:keyValue="1" wcm:action="add">
                   <Credentials>
                      <Domain>Fabrikam</Domain> 
                      <Password>MyPassword</Password> 
                      <Username>MyUserName</Username> 
                   </Credentials>
                   <Path>\\networkshare\share\drivers</Path> 
                </PathAndCredentials>
             </DriverPaths>
          </component>
       </settings>
    </unattend>
    
  2. Boot to Windows PE.

  3. At a command prompt, run Windows Setup and specify the name of the answer file. For example,

    setup.exe /unattend:C:\unattend.xml
    

    The device drivers in the path \\networkshare\share\drivers are added to the system during Windows Setup.

Adding a device driver during auditSystem

To add device drivers during the auditSystem configuration pass, add the Microsoft-Windows-PnpCustomizationsNonWinPE component to your answer file in the auditSystem configuration pass and specify the path for each device driver. After you run setup, log on to Windows and run audit mode using Sysprep.

To add a device driver during auditSystem

  1. Locate the device driver .inf files that you intend to install during audit mode.

  2. Add the Microsoft-Windows-PnpCustomizationsNonWinPE component to your answer file in the auditSystem configuration pass.

  3. Expand the Microsoft-Windows-PnpCustomizationsNonWinPE node in the answer file. Right-click DevicePaths and select Insert New PathAndCredentials.
    A new PathAndCredentials list item appears.

  4. For each location that you access, add a separate PathAndCredentials list item.

  5. 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, if you add two separate driver paths, then the first path uses the Key value of 1, and the second path uses the Key value of 2.

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

    <?xml version="1.0" encoding="utf-8" ?> 
    <unattend xmlns="urn:schemas-microsoft-com:unattend">
       <settings pass="auditSystem">
          <component name="Microsoft-Windows-PnpCustomizationsNonWinPE" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="https://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
             <DriverPaths>
                <PathAndCredentials wcm:keyValue="1" wcm:action="add">
                   <Credentials>
                      <Domain>Fabrikam</Domain> 
                      <Password>MyPassword</Password> 
                      <Username>MyUserName</Username> 
                   </Credentials>
                   <Path>\\networkshare\share\drivers</Path> 
                </PathAndCredentials>
             </DriverPaths>
          </component>
       </settings>
    </unattend>
    
  2. Boot to Windows PE, run Windows Setup and specify the name of the answer file. For example:

    setup.exe /unattend:C:\unattend.xml
    

    The answer file specified is cached to the system, so when you run audit mode, settings in the answer file are applied.
    Setup completes.

  3. Log on to Windows and run audit mode by using Sysprep. For example:

    sysprep /audit /reboot
    

    Windows reboots to audit mode. Before the user logs on, device drivers specified in the answer file are added to Windows.

Adding device drivers using DPInst

To use DPInst to install drivers, add a custom command to an answer file in the AuditUser configuration pass. For more information about DPInst command-line switches, see this MSDN Web site.

To add a device driver using DPInst

  1. Open Windows System Image Manager (SIM).
  2. Open your answer file.
  3. On the Insert menu, point to Synchronous Command.
  4. Click Pass 6 auditUser from the submenu.
  5. The Create Synchronous Command dialog box opens.
  6. In the Enter command line text box, enter the command, with parameters. Use the Order box to select the order of the commands to run.
  7. Click OK.

A RunSynchronous command in your answer file should look similar to the following example.

<RunSynchronous>
   <RunSynchronousCommand wcm:action="add">
      <Credentials>
         <Domain>MyDomain</Domain>
         <Password>MyPassword</Password>
         <Username>MyUsername</Username>
      </Credentials>
      <Description>MySynchCommand1</Description>
      <Order>1</Order>
      <Path>\\network\server\share\filename</Path>
      <WillReboot>OnRequest</WillReboot>
   </RunSynchronousCommand>
   <RunSynchronousCommand wcm:action="add">
      <Credentials>
         <Domain>MyDomain</Domain>
         <Password>MyPassword</Password>
         <Username>MyUsername</Username>
      </Credentials>
      <Description>MySynchCommand2</Description>
      <Order>2</Order>
      <Path>\\network\server\share\filename</Path>
      <WillReboot>OnRequest</WillReboot>
   </RunSynchronousCommand>
</RunSynchronous>

For more information about RunSynchronous, see the Windows Unattended Setup Reference.

See Also

Concepts

Add Device Drivers to an Offline Windows Image