How to programmatically enable/disable network interfaces? (Windows XP)

Using the netsh interface
Usage set interface [name = ] IfName
[ [admin = ] ENABLED|DISABLED
[connect = ] CONNECTED|DISCONNECTED
[newname = ] NewName ]

Try including everything inside the outer brackets:
netsh interface set interface name=”thename” admin=disabled connect=DISCONNECTED newname=”thename”

See also this MS KB page: http://support.microsoft.com/kb/262265/
You could follow either of their suggestions.
For disabling the adapter, you will need to determine a way to reference the hardware device. If there will not be multiple adapters with the same name on the computer, you could possibly go off of the Description for the interface (or PCI ID works well). After that, using devcon (disable|enable). Devcon is an add-on console interface for the Device Manager.

Leave a Comment