Driver applications install some of the information in different file formats. These information files are stored in “%SystemDrive%\Windows\inf” folder. These files are stored by the naming convention as OEMXX.inf and OEMXX.PNF where XX stands for some number eg. OEM05.inf and OEM05.pnf. Each driver application will put its INF and pnf files after the last number of OEM files like when you install driver if the last number of OEM file on the build is OEM05 then your driver will install its information files as OEM06.
So we cannot capture these driver files as they will be hardcoded as OEM number may change from machine to machine.
Different Methods to avoid hard coding of OEMXX files:
We use different techniques like use of setupapi.dll custom action and Difx merge modules to avoid hard coding of OEMXX files. But these methods are very much confusing and time taking though equally effective.
Another method to install driver is with DpInst.exe.
What is DpInst.exe:
Dpinst.exe is nothing but the component of DifX merge module. It identifies the driver files in the folder and installs OEM files automatically with desired number. DpInst stands for “Driver Package Installer”.
When directly opened, DpInst.exe runs a wizard-install mode that displays UI welcome dialog, license agreement and then it displays installation page. It performs following steps to install drivers.
- DPInst searches the directory where the DPInst executable (DPInst.exe) is located. DPInst also searches vendor-specified subdirectories under the directory where DPInst.exe is located. A vendor specifies the subdirectories by using the search and subdirectory XML elements in an optional DPInst descriptor file (DPInst.xml)
- Authenticates the driver packages.(signed or unsigned)
- Installs driver packages in the driver store
- Adds an Add or Remove Program entry in Control Panel that represents a driver package. (DPInst does not support this feature on Windows Longhorn.)
- Installs the driver packages on matching devices that are connected to a computer.
DpInst also provides command line switches as follows:
- /U <path to INF file> Uninstall a driver package (INF-file)
- /S, /Q Silent mode. Suppresses the Device Installation Wizard and any dialogs popped-up by the operating system.
- /LM Accepts unsigned driver packages and packages with missing files. These packages won’t install on the latest version of Windows
- /P Prompt if the driver package to be installed is not better than the current one.
- /F Force install inf the driver package is not better than the current one.
- /SH Scans hardware for matching devices and only copies and installs those drivers for which a device is present. Only valid for Plug and Play drivers.
- /SA Suppress the Add/Remove Programs entry normally created for each driver package
- /A Install all or none.
- /PATH <Path> Search for driver packages under the given path
- /EL Enables all languages not explicitly listed in the XML file.
- /L < LanguageID> Tries to use the given language in all UI. Useful for localization tests.
- /SE Suppress the EULA.
- /C Dump logging output to attached Console (Windows XP and above)
- /D Delete driver binaries on uninstall.
- /SW Suppresses the Device Installation Wizard, the OS might still pop-up user dialogs.
- /? /H Display Help
2. Packaging with the help of DpInst.exe:
While installing drivers with the help of DpInst, it is needed to be copied to the folder where driver files are present. Then with the help of above mentioned switches we will install drivers. Below steps are to be followed while using DpInst.exe for installing drivers in our captured application (as there would be no hard coded OEM information in vendor MSIs).
Step 1: Search for “*.inf” files in the captured package note down all the folders where INF files are present except windows\inf.
Step 2: Now compare .inf files we got in above step with the .inf files present under “Windows\inf” folder. Make sure all the INF files captured in Windows\inf folder are present in some other folder in your package(wsi)
Step 3: Delete the file “OEMXX.inf” from Windows\inf folder from your package.
Step 4: Copy DPInst.exe in the folder(s) you got in the step 1. (So as to get ease in writing custom action.)
Step 5: Now we will us MSI Script to execute DpInst.exe with appropriate command line switches. Below figures show how to write custom actions
Above steps are to be repeated for different folders where .inf files are present.