Subscribe to Windows IT Pro
May 14, 2009 12:00 AM

Use DevCon to Manage Finicky Hardware

One IT pro is using DevCon to break a sound barrier
Windows IT Pro
InstantDoc ID #101652
Rating: (0)

Next, I used Notepad to create a .cmd script named BAB's-SoundBlasterLiveOn.cmd, which contained the code

@echo off
devcon enable "PCI\VEN_1102&DEV_0002"

I put this script in the C:\Windows folder.

For my first test, I decided to try to add BAB's-SoundBlasterLiveOn.cmd to the Local Computer Group Policy Object (GPO) as a startup script. After opening the Group Policy Object Editor (gpedit.msc), I navigated to Local Computer Policy, Computer Configuration, Windows Settings, Scripts (Startup/Shutdown). I highlighted Scripts (Startup/Shutdown) in the navigation tree, selected Startup in the right pane, then clicked the Properties link. In the Startup Properties dialog box, I added BAB's-SoundBlasterLiveOn.cmd.

After rebooting and logging on, I found that my first test didn't work. The PC locked up. Apparently, the WDM driver was still getting enabled too soon.

For my second test, I added BAB's-SoundBlasterLiveOn.cmd to the OS's All Users Startup folder. (I wanted this script to run for all users on the PC.) In XP, this folder is typically found at C:\Documents and Settings\All Users\Start Menu\Programs\Startup. I rebooted the PC and logged on. In about 15 seconds, I saw a command window pop up, the WDM driver load, and the command window close. Voila—the sound card was successfully enabled!

Now that the sound card was enabled, I needed a way to automatically disable the card upon shutdown. Using Notepad, I created a .cmd script named BAB's-SoundBlasterLiveOff.cmd, which contained the code

@echo off
devcon disable "PCI\VEN_1102&DEV_0002"

Once again, I put this script in the C:\Windows folder.

In this case, the timing of the disablement wasn't as crucial, so I decided to try using the Local Computer GPO again. I added BAB's-SoundBlasterLiveOff.cmd to the Local Computer GPO, but this time I added it to the Shutdown Properties dialog box. (Highlight Scripts (Startup/Shutdown) in the navigation tree, select Shutdown in the right pane, then click the Properties link.) The GPO-invoked script successfully disabled the WDM driver.

DevCon isn't installed by default in Windows OSs. You can download it from the Microsoft article "The DevCon command-line utility functions as an alternative to Device Manager" (support.microsoft.com/kb/311272). The file that you download will contain devcon.exe for both 32-bit and 64-bit Windows OSs. You need to copy the appropriate version to your %systemroot%\system32 directory. After DevCon is installed, you can view the command-line syntax by running the command

devcon /?

in a command shell window.

With DevCon, you can use the asterisk (*) wildcard. For example, the command

devcon find PCI\*

will return the instance IDs and device names of the PCI devices currently present on the local computer. A similar command is

devcon findall pci*

This command lists all the PCI devices, even PCI devices that currently aren't present (e.g., they've been removed, they're software-enumerated devices that don't get installed until needed).

If you want to learn the status of each PCI device on the local machine (e.g., running, disabled), you can run the command

devcon status @PCI\*

Perhaps you aren't concerned with PCI devices but instead hard drives attached to IDE or SCSI interfaces. The easiest way I found to list the variety of device types present on a machine is

devcon status * | more

You can then use the command

devcon status @ide\*

to get the status of the IDE interfaces or

devcon status @scsi\*

to get the status of the SCSI interfaces.

These are only a few of the many operations you can perform with DevCon. It's a versatile tool you can use on local and remote computers. If you work with devices often and you're not familiar with this tool, you might want to give it a try.

Related Content:

ARTICLE TOOLS

Comments
    There are no comments to display. Be the first one!
You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.