Command line question

jenkinsjeremiah used Ask the Experts™
Is there a way to enable and disable hardware devices in NT 4 or Windows 2000 from the command line?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2007

You can start and stop services.

I do not remember anyway of doing this for devices, except for doing registry changes using the reg command with *.reg files

I hope this helps !


but will turning them off in the registry disable them immediately?

I really need to know what the device is before I could sugest anything
Learn Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.


It's a SCSI Card, but I assume that any utility that would be able to do this would be able to disable or re-enable any hardware device.

I'm really looking for the same functionality that you get in 'Device Manager' to disable or re-enable devices, only from the command line. I didn't see anything in the resource kit, and I've never heard of a utility either....I just thought you guys might know something I don't.

Theres little chance ofbeing able to stop the card itself. As far as disabling devices goes its hard to say. what is your aim? If its a raid controller, you could drag the disk offline? Physically removing Non-SCSI devices in NT4 would be pretty much impossible. 2000 has a fair chance though.


I'm not even sure why they want this....the backup team says that their print jobs fail, and that the only way to get it to work again is to disable the card in device manager, and then re-enable it.

This is common enough, that the want a script to do it for them....I've just never heard of doing that before.

I'm more of the opinion that they should figure out why it is hanging and fix it, but you know how people are =)

How the hell did they identify that a print job would continue if a SCSI adapter was stopped and started???

Anyway, you could always try stopping and starting the spooler service?


sorry...typo. BACKUP job.

And the answer is 'I have no idea' :)

Been a pleasure :-) Hope you find a solution... Its beyond me!

Bye, Gary

Intresting thread.. I also havent heard of command line device controls. I'd bet this could work with wscript.exe and a vbscript... Launch with wscript.exe //nologo //B file.vbs & it will not run "visibly"...
-The code to stop & start a specific device? I have no idea.
Top Expert 2007

Other options are to use an automated macro, or a remote control program like PCanywhere or the free VNC.

Why does this need to be a command line program ?

 I hope this helps !

-It sounds to me like they are developing a backup application & this would have to run from the command line on the local server..
I remember a utility from Microsoft named devcon.exe. Take a look at;EN-US;Q311272.  That's knowledge base article # 311272.  I think this is what you need.

"The Knowledge Base (KB) Article You Requested Is Currently Not Available"

I know about one DOS command to configure "system devices" = MODE - It might help

that's strange.  The above link must be incorrect.  Go to; click on the Search Knowledgebase Link, then scroll to the middle of the page and enter the article number - 311272

--here is an updated link:;[LN];311272

Below is a copy of the page---

 All Products  |  Support  |  Search  | Guide

 MS Product Catalog
 Microsoft Accessibility

 Developer Tools

 Knowledge Base
 Developer Support
 IT Pro Support
 Product Support Options
 Service Partner Referrals

 MSN Web Search

-------------------------------------------------------------------------------- Home
 MSN Home

 Contact Us
 Profile Center
 Training & Certification
 Free E-mail Account
  Home      Search      FAQs      Downloads      Newsgroups      Customer Service    
   Send      Print      Help    

 Provide us with feedback on this article
Product Support Centers  

 Windows DDKs  
 Windows 2000 - Developer  
Other Support Options  

 Contact Microsoft
Support Options, Phone Numbers, and Online Support
 Customer Services
Customer Care, Product Purchasing, Site and Production Information
Pose a question to other users. Discussion groups and Forums about specific Microsoft products, technologies, and services.
 Microsoft Knowledge Base Article - 311272
FILE: DevCon Command Line Utility Alternative to Device Manager
The information in this article applies to:
Microsoft Windows 2000 Driver Development Kit (DDK)
Microsoft Windows XP Driver Development Kit (DDK)

This article was previously published under Q311272
The "DevCon" utility is a command line utility that acts as an alternative to Device Manager. It allows you to enable, disable, restart, update, remove, and query individual devices or groups of devices. DevCon provides information that is relevant to the developer and is not available in Device Manager.

DevCon is designed for use on Windows 2000 and Windows XP. It will not work on Microsoft Windows 95, Windows 98, or Windows Millennium Edition.
DevCon is not redistributable. It is provided for use as a debugging and development tool. You can freely modify DevCon for private use. The sample demonstrates how to use the SetupAPI and CfgMgr32 APIs together effectively to enumerate devices and perform device operations.

The following file is available for download from the Microsoft Download Center:


Release Date: NOV-01-2001

For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:

119591 How to Obtain Microsoft Support Files from Online Services

Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on secure servers that prevent any unauthorized changes to the file.

The DevCon.exe file contains the following files:

File Description
I386\DevCon.exe 32-bit DevCon tool binary. This will not function completely on 64-bit Windows.
Ia64\DevCon.exe 64-bit DevCon tool binary.

NOTE: The source code for DevCon is also available in the Windows XP DDK (which is available from under DDK root\Src\Setup\Devcon, along with documentation.
Using DevCon
DevCon is a command-line utility with built-in documentation. If you run the command line devcon help, the following list of commands and descriptions will appear. The command devcon help command will give more detailed help on any command. With some of these commands, you can specify a remote target computer. These commands will work if you are using the 32-bit version of DevCon on WOW64.
Device Console Help:
devcon.exe [-r] [-m:\\<machine>] <command> [<arg>...]
-r if specified will reboot machine after command is complete, if needed.
<machine> is name of target machine.
<command> is command to perform (see below).
<arg>... is one or more arguments if required by command.
For help on a specific command, type: devcon.exe help <command>
classfilter          Allows modification of class filters.
classes              List all device setup classes.
disable              Disable devices that match the specific hardware or
                       instance ID.
driverfiles          List driver files installed for devices.
drivernodes          Lists all the driver nodes of devices.
enable               Enable devices that match the specific hardware or
                       instance ID.
find                 Find devices that match the specific hardware or
                       instance ID.
findall              Find devices including those that are not present.
help                 Display this information.
hwids                Lists hardware ID's of devices.
install              Manually install a device.
listclass            List all devices for a setup class.
reboot               Reboot local machine.
remove               Remove devices that match the specific hardware or
                       instance ID.
rescan               Scan for new hardware.
resources            Lists hardware resources of devices.
restart              Restart devices that match the specific hardware or
                       instance ID.
stack                Lists expected driver stack of devices.
status               List running status of devices.
update               Manually update a device.
Example DevCon Commands
devcon find *

Lists device instances of all devices that are present on the local computer.

devcon find pci\*

Lists all known Peripheral Component Interconnect (PCI) devices that are on the local computer (this command assumes that a device is PCI if it has a hardware ID that is prefixed by "PCI\").

devcon -m:\\test find pci\*

Lists all known PCI devices on the computer "test". (-m allows you to specify a target computer. Interprocess communication (IPC) access to the computer is required.)

devcon classes

Lists all known setup classes. The output contains the short nonlocalized name (for example, "USB") and the descriptive name (for example, "Universal Serial Bus controllers").

devcon listclass usb 1394

Lists all devices that are present for each class named (in this case, USB and 1394).

devcon find =ports *pnp*

Lists devices that are present that are a member of the ports setup class and contain "PNP" in their hardware ID.

devcon find =ports @root\*

Lists devices that are present that are a member of the ports setup class and are in the "root" branch of the enum tree (the instance ID is prefixed by "root\"). Note that you should not make any programmatic assumption about how an instance ID is formatted. To determine root devices, you can check device status bits. This feature is included in DevCon to aid in debugging.

devcon findall =ports

Lists "nonpresent" devices along with devices that are present for the ports class. This will include devices that have been removed, devices that have been moved from one slot to another, and, in some cases, devices that have been enumerated differently due to a BIOS change.

devcon status @pci\*

Lists the status of each device present that has an instance ID that begins with "pci\".

devcon status @ACPI\PNP0501\1

Lists the status of a specific device instance, in this case an Advanced Configuration and Power Interface (ACPI)-enumerated serial port.

devcon status @root\rdp_mou\0000

Lists the status of the Microsoft Terminal Server or Terminal Services mouse driver.

devcon status *PNP05*

Lists the status of all COM ports.

devcon resources =ports

Lists the resources that are used by all devices in the ports setup class.

devcon driverfiles =ports

Lists files that are associated with each device in the ports setup class.

devcon stack =ports

Lists the expected driver stack for the device. This includes device and class upper/lower filters as well as the controlling service.

devcon drivernodes @ROOT\PCI_HAL\PNP0A03

Lists all compatible drivers for the device "ROOT\PCI_HAL\PNP0A03". This can be used to determine why an integral device information file (INF) was chosen instead of a third-party INF.

devcon remove @usb\*

Removes all USB devices. Devices that are removed will be listed along with removal status.

devcon rescan

Rescans for new Plug and Play devices.

devcon update mydev.inf *pnp0501

Updates all devices that exactly match the hardware ID "*pnp0501" in order to use the best driver in Mydev.inf that is associated with the hardware ID *pnp0501. Note that this will force all devices to use the driver in Mydev.inf even if there is a better match already on the system. This is useful when you want to install new versions of drivers during development before you obtain a signature. It only affects the devices that match the specified hardware ID, and not child devices. If the specified .inf file is unsigned, Windows may display a dialog box that prompts you to confirm whether the driver should be installed. If a restart is required, this will be reported and DevCon will return with an error level of "1". If you specify "-r", this will cause a restart to occur automatically if one is required.

devcon -r install Windows directory\Inf\Netloop.inf *MSLOOP

Installs a new instance of the Microsoft loopback adaptor. This will create a new root-enumerated device node to allow you to install a "virtual device," such as the loopback adaptor. This command also restarts the computer silently if a restart is required.

devcon disable *MSLOOP

Disables all devices that have a hardware ID that ends in "MSLOOP" (including "*MSLOOP").

devcon enable '*MSLOOP

Enables all devices that have a hardware ID of "*MSLOOP". The single quotation mark indicates that the hardware ID must be taken literally (in other words, the asterisk ["*"] actually is an asterisk; it is not a wildcard character).

devcon restart =net @'ROOT\*MSLOOP\0000

Restarts the loopback adaptor "ROOT\*MSLOOP\0000". The single quotation mark indicates that the instance ID must be taken literally.

Devcon classfilter upper !filter1 !filter2

Deletes the two specified filters.

Devcon classfilter lower !badfilter +goodfilter

Replaces the "badfilter" with the "goodfilter".

Devcon will return an error level for use in scripts:

"0" indicates a success.
"1" indicates that a restart is required.
"2" indicates a failure.
"3" indicates a syntax error.

If you specify -r and a restart is required, the restart will occur without warning once all devices have been processed.
If you specify -m:\\computer and the command will not work for a remote computer, an error will be reported.
Devcon allows wildcards in instance IDs for interactive convenience. Do not make any assumption about the format of an instance ID from computer to computer and from operating system version to operating system version.
Last Reviewed: 8/6/2002
Keywords: kbDSupport kbfile kbhowto KB311272

  Send      Print      Help    
 Last reviewed  Tuesday, August 06, 2002

) 2002 Microsoft Corporation. All rights reserved.  Terms of use  Privacy statement  Accessibility  
seemayur forgive me for not reading your copy of the knowledgebase article.  I'd suggest a short version before you copy the entire article unless you want everyone to glass over....

It sounds to me like something is causing a problem when they print.  Can I suggest that they look at their virus software and EXCLUDE the spool directory...  Its only a guess.

However, from the dos prompt NET STOP <service name> will stop the service if its a service.

interesting.... i don't have any idea on how to disable hardwares from command line.

If backup jobs failed, why don't ask the backup team to send the backup job logs (in summary) here ??? veritas, legato, Arcserve have all this logs...

DevCon is designed for use on Windows 2000 and Windows XP. It will not work on Microsoft Windows 95, Windows 98, or Windows Millennium Edition.

-What about NT4 ??


Devcon looks like it will do exactly what I need. =)


Right on! thanks.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial