Shortcut to enable/disable hardware
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.
DevCon
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:
PCI\VEN_1969&DEV_1048&SUBSYS_82261043&REV_B0\4&625283&0&00E5: 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)
Else
ShellExecute("devcon","enable PCI\VEN_1969","","",@SW_HIDE)
EndIf
Exit
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.
Overall
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



Thanks, its much faster then going to Network Connections!
@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.
[...] 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. [...]