Wednesday, October 7, 2009

Installing Windows 7 drivers from the command line

If a Windows 7 PC with “unknown” (aka Driver missing) will simply connect to Windows Update, check if a matching driver is found and install it. This works fine when using this at home, but it does not work if you are inside a corporate network.

In this case, a Windows Server Update Services (WSUS) is used and it does not contain any drivers. Therefore, you need to manually download the drivers you need, put them in a folder and then use DPinst.exe to install the drivers.

To get this tool, you need to download Windows Driver Kit Version 7.0.0 – a hefty 610 MB download! Burn the ISO image to a CD or open it with WinRAR, and start the setup. Inside the setup, you only need to select “Tools”.

Once the Installation is finished, you can copy dpinst.exe from the \redist\DIFx\dpinst\MultiLin folder:

image

 

 

 

 

Each folder contains a version of DPInst.exe for the architecture the folder is named. I decided to simply rename each version of DPInst.exe and append the architecture to it, so I can copy all version to the same folder.

Create a folder on a network drive, e.g. W7_OnlineDrivers_1 and copy the renamed DPInst.exe files to it. My folder currently looks like this:

image

 

 

 

 

 

What DPInst.exe needs, is DPinst.xml with several settings it (you could also specify them on the command line, but I liked the XML idea more).

<?xml version="1.0" ?>
<dpinst>

<search>
<subDirectory>*</subDirectory>
</search>
<enableNotListedLanguages/>
<suppressEulaPage/>
<quietInstall/>

<!-- Only install drivers for online hardware -->
<scanHardware/>

<!-- No driver signature required -->
<legacyMode/>

</dpinst>

Most settings should be easy to understand, the complete reference can be found on this MSDN page. However, the scanHardware needs some explanation.

If this switch is found inside the file, DPInst.exe will only install drivers that are currently connected to the computer. All other drivers are not installed.

That’s the reason why I called the folder W7_OnlineDrivers. Since it will install only drives that are actually needed on the system, this folder can contain dozens of drivers – drivers that aren't needed will not be installed.

If scanHardware is NOT defined, DPInst.exe will install all drivers, regardless if a device is visible or not. This is basically the same as using pnputil.exe –a C:\<path>\*.inf.

Finally, we need a batch file to start DPInst.exe. I used the following in _install.bat for this:

"%~dp0dpinst_x86.exe" /c
pause

The /c parameter simply indicates that all output should go to the console instead of a log file. That way, you can easily see what is going on. As soon as I have a x64 Test machine ready, I will expand the batch file a little bit so it will execute dpinst_x64.exe on a 64 bit machine and dpinst_x86.exe on a 32 bit machine. For now I stick with the 32 bit version.

Once this is all setup, we are ready to install our first driver. The test computer I currently use had all drivers installed automatically, except for the sound card:

image

 

 

 

 

 

Right click the entry with the yellow exclamation mark and go to the “Details” tab. Inside this, select “Hardware-IDs”. These will list all PCI IDs for the device.

image

 

 

 

 

 

 

 

In this case, VEN_8086 and DEV_2445 should be enough to identify the device, so we will now search Windows Update for a driver:

http://catalog.update.microsoft.com/v7/site/Search.aspx?q=ven_8086%26dev_2445

Please note that this site is using an ActiveX control and therefore you will have to use Internet Explorer. The results of this query should look something like this:

image

Note: Normally you should be able to pick any driver and use it, however the first one I picked (Realtek) contained a file WITHOUT a digital signature and thus DPInst.exe exited with error code 80010300. So, if there is a Microsoft driver available, use it. They always work.

Simply click on the Add button of the driver you are interested in, click on View Basket and download the package, a *.CAB file.

Open the CAB file (with WinRAR for example) and expand all files in it to a new folder inside the W7_OnlineDrivers_1 folder.

Now you can give it a try and execute _Install.bat. If everything has been done right, Windows will install the driver for the sound card and activate it automatically. If not, check the output for any errors.

As a final note: If you download a new driver, just remove the folder containing the old one and execute DPInst.exe again. DPInst.exe will not just install new drivers, it also updates drivers. That’s a great way to keep the drivers current without any extra hassle.

 

UPDATE 2010-12-15: See this post why DPInst sometimes (especially with Network cards) chooses the wrong driver.

4 comments:

  1. Thank you *so* much for this post. I spent half the day yesterday trying to get devcon to work to install a USB3 driver, with no success. This morning I tried your technique first thing and *poof*, instant success. I will use this method to initially install workstations and maintain them in my automated install/maintenance system. Thanks again, from North Carolina, USA.

    ReplyDelete
  2. You save my life! Thank you

    ReplyDelete
  3. Very helpfull, this helped me to solve my thing.

    Thanks

    ReplyDelete
  4. works like a charm.. :) thanks

    ReplyDelete