DPInst exit codes explained

The DPInst executable returns a decimal value. We cand decode it find out what the outcome of the installation was.

First, the value needs to be convert the decimal value into hexadecimal. The easieast way to do it is using the Calculator. Switch to Programmer View, select Decimal, enter the value, click on Hex. That’s it.

You’ll obtain a value like 0xWWXXYYZZ(or less digits – in this case, the zeros in front won’t be shown). Then, we separate the pairs. Basically, we`ll get 4 hex numbers. This is their meaning:

0xWW If a package couldn’t be installed, this will be set to 0x80.
If a reboot is needed, its value will be 0x40.
Otherwise, it will be 0x00.
0xXX  Number of driver packages that could not be installed
0xYY  Number of driver packages that have been copied to the driver store but haven’t been installed on a device
0xZZ  Number of driver packages that have been installed on a device

We have made available a calculator that will decode this value for you, and that will also allow you to calculate the returned value of different scenarios.

DPInst Switches

DPInst is a tool that allows us to install signed Plug and Play (PnP) function drivers, as well as signed class filter drivers. It can also run in legacy mode, to install unsigned drivers. Starting with Windows 7, DPInst is part of the WDK (Windows Driver Kit).

DPInst can be run interactively or silently. DPInst tries to install the driver packages that can be found in the working directory. Both scenarios (interactive or silent) accept the use of a XML file that will contain the configuration flags. However, several switches can be used to modify the operating mode of DPInst:

/a installAllOrNone=ON; DPInst will install the drivers only if all of the drivers in the installation package can be installed.
/c Will display log messages in the Command Prompt window where dpinst has been called.
/d deleteBinaries=ON; After the installation of a driver package, the binary files that were copied to the system will be deleted.
/el enableNotListedLanguages=ON; It enables all supported languages that are not not mentioned in the DPInst descriptor file.
/f forceIfDriverIsNotBetter=ON; This forces the installation of the driver package, even if the driver currently installed on the device is a better match than the new one.
/h, /? or /help Displays help info. If called in a Command Prompt, the info will be displayed there. Otherwise, there’ll be a message box.
/l languageId Change the language of the installation.
/lm legacyMode=ON; Unsigned drivers will be accepted. However, Windows driver signing requirements apply to the installation of a driver package from the driver store.
/q or /s quietInstall=ON; It suppresses the display of wizard pages, user dialogs and other messages.
/p promptIfDriverIsNotBetter=ON; A dialog will be displayed in case the driver being installed is not a better match than the one currently installed on the device.
/path workingDirectory Sets the working directory, where DPInst will look for the driver packages.
/sa suppressAddRemovePrograms=ON; The driver package won’t appear in Programs and Features, in Control Panel.
/se suppressEulaPage=ON; The EULA page won’t be displayed
/sh scanHardware=ON; A driver package will be installed for a PnP function driver only if the driver package matches a device that is currently configured in a computer and if it’s a better match than the currently installed driver.
/sw suppressWizard=ON; No wizard pages will be displayed.
/u infFilePath This will uninstall a driver package whose INF path is mentioned in the command line. The path is relative to the directory containing DPInst.exe

For packaging purposes, the most used switches would be /sa /sw /se, and occasionally /f and /lm (in extreme scenarios)

For more info on DPInst, please check our other articles.

DPInst Exit Code Calculator

Below you can find an exit code calculator for DPInst.
The first one explains the outcome of a dpinst execution, while the second one calculates the exit codes based on what the expected outcome.

Decode exit code
Decimal value to be decoded:


Calculate expected exit code based on the estimated outcome
Number of driver packages that will be installed on a device
Number of driver packages that will be copied to the driver store
Number of driver packages that will fail
Reboot needed

Calculated Hexadecimal Exit Code:

Calculated Decimal Exit Code (this is what DpInst will return!):

Signing a driver and installing it silently

 

Signing the driver(s)

Sometimes we are in the unpleasant situation of having to install silently a driver that is unsigned (or the certificate used has expired). If we use DpInst, then the solution is to sign it ourselves.

How do we do that?

1. First, we need the Windows Driver Kit. If you don’t have it already, check this article.

2. Start the X86 Free Build Environment. You can find a shortcut under (All) Programs\Windows Driver Kits\Build Environments\Windows XP\

3. If we don’t have a certificate file (.cer) already, then we need to create one now.

3.1. Run: makecert.exe -r -pe -ss PrivateCertStore -n CN=FQDN_here Your_Certificate_Name.cer

More info on FQDN

3.2. Copy the newly created .cer file to the folder containing the .inf (the drivers) that needs to be signed

3.3 Change directory to the same folder in the console.

4. Run: stampinf.exe -f Inf_Name_here -d * -v Inf_Version_here

5. Run: inf2cat.exe /driver:.\ /os:XP_X86,Server2003_X86,7_X86

6. Run: signtool.exe sign /v /s PrivateCertStore /n FQDN_here /t http://timestamp.verisign.com/scripts/timestamp.dll cat_filename_here.cat

Be aware that the signtool command line might fail if you use a proxy that blocks the reply from the timestamp server.

Installing the custom signed driver

We will install the newly signed driver with DpInst.

1. We need a tool called CertMgr.exe. It’s part of Windows SDK, which can be downloaded from here. This executable should be included in your future package and it is used to import certificates (among other operations).

2. In a normal console, run: certmgr.exe /add Your_Certificate_Here.cer /s /r localMachineRoot

and certmgr.exe /add Your_Certificate_Here.cer /s /r localMachine trustedpublisher

These will import the certificate and add you to the trusted publishers. Local admin permissions needed.

3. Run dpinst.exe /sa /se /sw 

4. Check the exit code and the log file C:\windows\dpinst.log to see if the installation was successful.

More info on how to use DpInst and its exit codes you can find here.