Shortcut to enable/disable hardware

AutoIt Local networks are wonderful but when out of your personal control they might come with nasty side effects (like automatic updates trashing processor or proxy choking browser).

I couldn’t toggle network connection either (even with admin rights) so that left me switching network adapter on and off in Device Manager.

That got boring fast so I looked up way to boil down enabling and disabling hardware into single shortcut.


Device Manager is purely graphical utility that makes it inconvenient to automate.

Luckily Microsoft also provides DevCon which is clone of Device Manager in form of command line utility.

Figure out device ID

DevCon is developer-grade utility so it is much less user friendly than average CLI stuff in Windows. To have it disable or enable device it must be provided with hardware ID of one.

I had googled this nice trick to simplify search in console output and run:

devcon find * | find "Atheros"

where Atheros is brand of my network card. This returned few cryptic lines with one looking like what I actually need:

Atheros L1 Gigabit Ethernet 10/100/1000Base-T Controller

Since PC isn’t really full of network cards PCI\VEN_1969 is enough for DevCon to identify device.

Splice with AutoIt

Two separate shortcuts to enable and disable still sounded troublesome (and produced flashing console windows) so I combined them in single AutoIt script:

If Ping("proxy.company.com") Then
ShellExecute("devcon","disable PCI\VEN_1969","","",@SW_HIDE)
ShellExecute("devcon","enable PCI\VEN_1969","","",@SW_HIDE)

Script pings proxy server (revenge!) and according to response or lack of any uses DevCon (in hidden console window) to enable or disable network adapter.


DevCon is hardly utility for daily use but when there is need to control hardware – it is extremely powerful and easily scriptable.

Home&download http://support.microsoft.com/kb/311272

Related Posts


  • ks #

    Thanks, its much faster then going to Network Connections!
  • Rarst #

    @ks For network connection would be easier to drag connection to desktop (creates specialized shortcut) and just use that. :) Method in post is when that is prohibited by policies and for messing with hardware in general.
  • Turn Off Computer Hardware With A Single Click #

    [...] Rarst inspired me to take a closer look at the command line utility devcon which has been created by Microsoft. Devcon is basically 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. [...]
  • Roland #

    This was just what I needed. Took me awhile to get working, but I now have a keyboard shortcut to turn off network like my laptop has! Great job!
  • sg #

    Keep in mind that this may cause Windows' activation to get revoked because of "significant hardware changes" if you reboot with the disabled device. Happened to me on Windows XP. Hooray for horrible DRM systems, I guess.
  • Rarst #

    @sg Ouch, this seems way too minor to reset activation. Could it be that other hardware changed before and it was "last straw" kind of a thing? I've never actually looked to deeply into logic of activation reset. Just one of the stupid DRM things you get used to. :(