Use DevCon To Install Device Drivers Remotely

If you have to install a device driver on a lot of computers, give DevCon a try.

M. Hakan Can

September 7, 2009

3 Min Read
ITPro Today logo in a gray background | ITPro Today


My company purchased smart card readers for an electronic signature application. To use the smart card readers, drivers needed to be installed. Because we had nearly 500 computers, manually installing the drivers wasn't practical. To save a lot of time and manpower, we used DevCon (devcon.exe). This utility lets you query, load, and remove device drivers from the command line.

DevCon isn't installed by default. You can install it from the SupportTools directory on the Windows Server 2003 SP1 CD-ROM or download it from the "The DevCon command-line utility functions as an alternative to Device Manager" web page. (This web page also includes helpful information about how to use DevCon.)

The solution we came up with involved putting DevCon and the driver on a share, then using a batch file to install DevCon on each user's computer. I'll describe the steps we took in case you run into a situation in which you have to install a driver on numerous machines.

The first step was to put DevCon and the driver on a share so that they could be copied to users' systems. On the share, we created the carddriveromnikey and carddriverdevcon directories, giving them Everyone – Read permissions. We put the driver file in the \mainservercarddriveromnikey directory and devcon.exe in the \mainservercarddriverdevcon directory.

After the shares were prepared, we turned our attention to finding the hardware ID for the card reader. After some testing we discovered that if you plug in an unknown USB device (such as a smart card reader), click Cancel to close the New Hardware Found wizard, then run DevCon, you can obtain its device ID. The DevCon command we used was

devcon find USB*

As Figure 1 shows, it produces a list of USB ports and the device IDs of the USB devices connected to those ports.


Figure 1: Sample output from DevCon


In the sample output in Figure 1, I highlighted the important elements. USBVID_076B&PID_3021 is the hardware ID. Smart Card Reader USB tells us that the hardware's driver hasn't been loaded yet. After loading the driver, this will read CardMan 3x21. (For more information about the various elements in device IDs, see the Reader to Reader article "Use DevCon to Manage Finicky Hardware".)

With the card reader's hardware ID in hand, it was time to write the batch file. UpdateCardDriver.bat, which Listing 1 shows, first checks to see whether the driver is already present. If it exists, the script ends. If it doesn't exist, the batch file copies DevCon to the %systemroot%system32 directory on the user's computer, uses DevCon to install the card-reader driver, then removes the card reader. Although the card reader is removed, the driver stays in the system. If you don't remove the card reader, another card reader will be added to the system each time the computer restarts.


Listing 1: UpdateCardDriver.bat


UpdateCardDriver.bat needed to be executed on every computer on which we wanted to install the driver. Because we had nearly 500 computers, we chose to use a Group Policy Object (GPO) startup script. (For information about how to add a batch file to a GPO, see the web-exclusive article "Adding Startup Scripts to GPOs".) After restarting their computers, users were able to attach and use the smart card reader hardware on any USB port on their system.

You can download UpdateCardDriver.bat by clicking the Download the Code Here button at the top of the page.

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like