473,479 Members | 2,115 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How can I disable a device in windows using python

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.

Thanks,
Senthil

Feb 27 '07 #1
4 14122
Phoe6 wrote:
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.

Thanks,
Senthil

You didn't even tell us what operating system you are using, but even
so, I'm going to say you probably won't find a Python function to do
this. However, if you tell us how you would disable a card from outside
of Python, we'll see if we can find a way to do it from within Python.

Things you might want to tell us:

What OS.
What device(s)
Exactly what "disable" means for each.
How the OS allows you to enable/disable each.
Anything else that might help us.
Gary Herron

Feb 27 '07 #2
Phoe6 wrote:
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).
Since you mention WMI I'm going to assume you're on
Windows (although if you hadn't we'd have had no idea!).

Running the terms: wmi disable network card
past Google came up with this page:

http://channel9.msdn.com/ShowPost.aspx?PostID=158340

where the first answer to the question "Is there any way to
programatically disable an NIC" points us to this page:

http://www.mcpmag.com/columns/articl...itorialsID=619

which uses the Shell application object to automate the control
panel (and, by the way, I'd no idea you could do this).

You should be able to recreate this fairly easily from
Python using the pywin32 extensions, and in particular the
win32com.client tools. To get you started:

<code>
import win32com.client

shell = win32com.client.Dispatch ("Shell.Application")
control_panel = shell.Namespace (3)
for item in control_panel.Items ():
if item.Name == "Network and Dial-up Connections":
network_connections = item
break
else:
raise Exception ("networking not found")

# you now have the networking item

</code>

TJG
Feb 27 '07 #3
"Phoe6" <or*******@gmail.comwrote:
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&214 CFA8C&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&214 CFA8C&1&00E2: Disabled
1 device(s) disabled.

C:\>devcon enable *DEV_4222*
PCI\VEN_8086&DEV_4222&SUBSYS_10418086&REV_02\4&214 CFA8C&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.
Feb 27 '07 #4
On Feb 27, 2:21 pm, Duncan Booth <duncan.bo...@invalid.invalidwrote:
Hi all,
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).
Thanks for the reply, this is very helpful.

Thanks,
Senthil

Feb 28 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
6470
by: Kevin Altis | last post by:
Does anyone have experience running Python from a USB storage device? Whether it is the need for doing a demo of your application, doing a bit of consulting, or just showing off Python, it would be...
7
10265
by: Fazer | last post by:
Hello, I have a MP3 and I want to access the songs in them. I was wondering if Python could help me do that. I understand that this can be done using Linux by mountig it as a file system, but...
10
7146
by: Wouter van Ooijen | last post by:
I want to use Python to interface with an USB HID device (not a keyboard or mouse, just something that uses the HID driver to avoid the need for a specific driver). Is this possible in pure Python...
0
2129
by: Carl Waldbieser | last post by:
**** Post for FREE via your newsreader at post.usenet.com **** When using urllib2.urlopen() on my Windows 2000 machine at work, I was puzzled that I kept getting back authentication errors from...
2
8851
by: RootSpy2006 | last post by:
Hi All, Problem Definition: --------------------- Microsoft Wirelss Keyboard works in BIOS but does not work when booting into windows. Discovered Work-around: -----------------------------...
7
13858
by: Michael | last post by:
I'm exploring how to programmatically disable/enable devices in a system using C#. -MH
1
1744
by: walterbyrd | last post by:
I want my python app to read a file from a pocketpc mobile device, if possible. Assume I am running windows-xp, and activesync 3.8. Assume I have "exported" the file. As I understand it,...
1
3953
by: solanki.chandrakant | last post by:
Hi All, i m working on Linux Fedora Core 4. i have to develop one program in that i have device id. Based on given device id i have to enable/disable particular device id. i have to work with...
37
4985
by: Vince C. | last post by:
Hi all. I've installed Bloodshed Dev-C++ on a Windows 2000 SP4 machine. I'm using MinGW 3.4.2. I'd like to temporarily disable standard functions to write to stderr, i.e. for instance...
0
6899
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7019
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6719
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5312
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4757
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
2980
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
2970
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1288
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
166
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.