Phoe6 said:
Hi all,
I am trying to disable the NIC card (and other cards) enabled in my
machine to test diagnostics on that card.
I am trying to disable it programmatic using python. I checked python
wmi and i could not find ways to disable/enable, (listing is however,
possible).
Where should I look for to enable/disable devices in python.
Assuming you mean windows:
If you don't mind doing it by spawning an external program try
downloading devcon.exe from Microsoft's website
(
http://support.microsoft.com/kb/311272).
Using devcon you can enumerate devices, enable or disable them and a
variety of other things. For example, on my current machine I can
disable or enable my wireless card with:
C:\>devcon find *DEV_4222*
PCI\VEN_8086&DEV_4222&SUBSYS_10418086&REV_02\4&214CFA8C&1&00E2: Intel(R)
PRO/Wireless 3945ABG Network Connection
1 matching device(s) found.
C:\>devcon disable *DEV_4222*
PCI\VEN_8086&DEV_4222&SUBSYS_10418086&REV_02\4&214CFA8C&1&00E2: Disabled
1 device(s) disabled.
C:\>devcon enable *DEV_4222*
PCI\VEN_8086&DEV_4222&SUBSYS_10418086&REV_02\4&214CFA8C&1&00E2: Enabled
1 device(s) enabled.
The most tricky bit is finding the correct id in the first bit, just do
a wildcard find command and look for something appropriate. The enable
and disable are exactly the same as the equivalent commands from the
network connections window or the device manager. Oh, and don't forget
if you want to use the full id for a device you'll have to escape the &
characters or quote the argument.