7

I need to have a driver installed in my customers' computers. Unfortunately, the only way to do this right now is having Windows show its "Hardware Update Wizard" when the device is plugged in, and then have the user do the following:

  • select "No, not this time",
  • select "Install from a specific location (Advanced)",
  • check or uncheck appropriate checkboxes and select the folder that contains the drivers

All of which is slow and unfriendly for a non technically savvy user. For the people who must install the device in many computers, it's a repetitive and annoying process too.

So, I'm trying to write a very simple program that will prompt the user to plug in the device. Then the program will do the same steps above automatically. My questions:

  • I wonder if there is a Windows API that looks for drivers in a folder, since that's what the Wizard does.
  • I've just discovered the function DriverPackageInstall. Would passing the .inf file as a parameter do what I want? (I'll be writing code to test this in the meanwhile, just give me some time to download the Windows Driver Kit and set up a project...).
  • Any other suggestions?
Jong Bor Lee
  • 3,805
  • 1
  • 24
  • 27
  • @David Heffernan: No. I just have a folder with the .inf file and some files that are copied to to System32 during installation. – Jong Bor Lee Mar 10 '11 at 20:24
  • @Jong Can you just get your users to right click on the .inf and select install? They may need to elevate. Possibly cleaner would be ask driver vendor to supply an .msi or perhaps even write your own. – David Heffernan Mar 10 '11 at 20:26
  • @David Heffernan: nope, unfortunately right click + install doesn't work. – Jong Bor Lee Mar 10 '11 at 20:37
  • @Jong I think you should contact the vendor. – David Heffernan Mar 10 '11 at 20:39
  • What version is the operating system, Windows XP or higher? – Ilya Mar 15 '11 at 12:18
  • Oops, sorry all, I haven´t been able to pay much attention to the question since other things have taken precedence, so I haven't had time to setup a Windows Driver Kit project to test any of the suggestions. The operating system is Windows XP or higher indeed. – Jong Bor Lee Mar 15 '11 at 12:24
  • 1
    dpinstall.exe is the way to go. – Tedd Hansen Mar 15 '11 at 12:25

3 Answers3

5

You did not specify which version of Windows.

On Windows 7 there`s pnputil:

c:\>pnputil -?
Microsoft PnP Utility
Usage:
------
pnputil.exe [-f | -i] [ -? | -a | -d | -e ] <INF name>
Examples:
pnputil.exe -a a:\usbcam\USBCAM.INF      -> Add package specified by USBCAM.INF
pnputil.exe -a c:\drivers\*.inf          -> Add all packages in c:\drivers\
pnputil.exe -i -a a:\usbcam\USBCAM.INF   -> Add and install driver package
pnputil.exe -e                           -> Enumerate all 3rd party packages
pnputil.exe -d oem0.inf                  -> Delete package oem0.inf
pnputil.exe -f -d oem0.inf               -> Force delete package oem0.inf
pnputil.exe -?                           -> This usage screen

programmatically, you can use DiInstallDriver

John
  • 5,561
  • 1
  • 23
  • 39
  • I forgot to specify which version of Windows indeed. Most of the computers where this driver is going to be installed are XP, so I'm afraid pnputil and DiInstallDriver won't be available. – Jong Bor Lee Mar 15 '11 at 12:26
4

There are several ways and some depend on the type of device you have.

There are several tools for installing driver packages.

  1. DpInst is a complete application which can show a wizard and be customized to install a driver package

  2. DifXApp builds a msi package which can be used to install drivers

  3. DifxApi is the API which DpInst and DifxApp use to install drivers.

  4. Directly using the SetupApi functions.

    Here the functions SetupCopyOEMInf and UpdateDriverForPlugAndPlayDevices provide the corresponding entry points for a driver setup. These are contained in the WinSDK.

DpInst/DifxApp/DifxApi are part of the Windows Driver Kit (WDK).

Christopher
  • 8,912
  • 3
  • 33
  • 38
1

DifX (found in the Windows DDK) is the Microsoft recommended way for installing drivers. DPInst is the standalone tool and DifX API is the programmatic way.

If the driver is signed, you can use DPInst (or DifX API) to preinstall it and then it'll be installed (without any wizards or prompts) as soon as the user inserts the hardware.

If the driver is unsigned (i.e. has no signed .cat file), then:

  • on Windows Vista and higher, you can sign it yourself (typically with a certificate you purchase from a CA, though self-signing might be possible)
  • on Windows XP, you're doomed (unless you apply some real ugly hacks)
Ilya
  • 5,533
  • 2
  • 29
  • 57