Rarst inspired me to take a closer look at the command line utility devcon which has been created by Microsoft. Devcon is a command line version of the Windows Device Manager.
We recently published an energy saving article that contained a tip to disable computer hardware to save power which is especially useful for mobile computer systems like laptops or netbooks.
It is possible to write a simple batch script that can turn computer hardware off. Might be a handy for users who connect their mobile computer to a power source and use it on the road as well. They would simply turn off the unnecessary computer hardware on the road and turn it on again once it is connected to a power source again.
The creation does not require programming skills but you need to know a bit about the computer hardware installed on your system. Not all hardware should be disabled, possibilities include
- Audio Devices
- Network Adapters
- Wireless Networking Adapters
- CD, DVD and Blu-Ray drives
- Floppy drives
- webcams, card readers and other peripherals
You need three commands to work with devcon.
- devcon find
- devcon disable
- devcon enable
Start by downloading devcon from the official Microsoft website. Unpack it to a directory of your choice. It might be a good idea to put it into a directory that is listed in the system path of the operating system, e.g. /system32.
Open the Windows command line with [Windows R], [cmd], [enter].
Enter devcon find * to get a listing of all hardware devices. This can be a long list, you can use the following command to find a specific device (the command is case sensitive):
devcon find * | find “computer hardware identifier”
To find all Creative devices one could enter
devcon find * | find “Creative”
The device in the screenshot above would be the Creative Soundblaster X-FI sound card. To disable that sound card one would use the following command
devcon disable PCIVEN_1102
It is enough to add the unique identifier for the hardware device. Here are some tips to make the most out of the find command:
Find all PCI devices
devcon find * | find “PCI”
Find all USB devices
devcon find * | find “USB”
All that needs to be done now is to collect the unique identifiers for all computer hardware devices that should be turned off at times.
Create a new text document on the computer, name it disable.bat. Right-click it, select edit and add as many devcon disable lines to it as you want.
devcon disable PCIVEN_1102
devcon disable PCIVEN_1317
devcon disable USBVID_1532
Now create a second batch file, name it enable.bat and use the following code (you basically exchange disable with enable)
devcon enable PCIVEN_1102
devcon enable PCIVEN_1317
devcon enable USBVID_1532
That’s a basic script. You could add echo commands to it, combine the two scripts into one and improve it further. The basic script on the other hand does what it is supposed to do.