You can use an answer file to automate the installation of the drivers when the computer is booted to audit mode. The following table describes the different configuration passes and how they are used to add device drivers using an answer file.

Configuration Pass Description Adding device drivers

auditUser

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

The auditUser configuration pass 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 Get the WDK and the WLK.

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 configuration pass runs only if the computer is booted 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 Windows Setup runs, the answer file is cached. When the Sysprep is used 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.

Alternately, the PNPUtil tool can be used to add, remove, and enumerate drivers on a running operating system. For more information about using PNPUtil to add or remove plug and play drivers, see Install a Plug and Play Device. You can also use DPInst to install detected drivers on a running operating system. 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 Get the WDK and the WLK.

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, boot Windows to audit mode. You can either run the Sysprep command with the /audit option to configure the computer to start in audit mode the next time it boots or, in the answer file, configure the Microsoft-Windows-Deployment\Reseal\Mode setting to audit. For more information on this setting, see the Windows® Unattended Setup Reference.

To add a device driver during the auditSystem configuration pass

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

  2. Open Windows System Image Manager (Windows SIM). Click Start, point to Programs, point to Microsoft Windows OPK (or Windows AIK), and then click Windows System Image Manager.

  3. Open your answer file and expand the Components node to display available settings.

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

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

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

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

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

    <?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="http://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>
    
  9. Boot to Windows Preinstallation Environment (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.

  10. Run the Sysprep command with the /audit option to configure the computer to start in audit mode the next time it boots. For example:

    sysprep /audit /reboot
    
    When Windows reboots to audit mode, device drivers specified in the answer file are added.

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 options, see this MSDN Web site.

To add a device driver using DPInst

  1. Open Windows SIM.

  2. Open your answer file.

  3. On the Insert menu, point to Synchronous Command.

  4. Click Pass 6 auditUser on the submenu.

    The Create Synchronous Command dialog box opens.

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

    Note:

    You can add a command here to add any driver packaged in an executable that can be silently installed.

  6. 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 the RunSynchronous command, see the Windows® Unattended Setup Reference.

See Also