|
-
Aug 9th, 2011, 02:25 PM
#1
Thread Starter
Lively Member
[RESOLVED] How to enable/disable NIC (network adapters) ?
Hi guys,
I want to write a small program to just enable/disable two network adapters.
I searched over google and I found a few C# codes but didn't understand anything. I heard something called WMI. It seems they are other ways like enabling registry (which sounds wierd for me) or using command lines.
I really don't know which way should be used althought I didn't find any code to those either. please show me something that works in win xp & vista & seven.
Because user want two switch between two NIC by enable one and disabling another one, I think I should first get a list of network adapters, then let user specify.
I know It can be done easily by going to the network settings directly and do it by right clicking. But they want to do it through a program with single click.
I hope you can help. Thanks in advance
Edit: I was able to get a list of adapters using WMI, Here is the page If someone wanted to take a look.
Last edited by xperator; Aug 12th, 2011 at 01:21 PM.
-
Aug 9th, 2011, 02:34 PM
#2
Re: How to enable/disable NIC (network adapters) ?
I don't know of a managed way, but you should be able to use the Netsh command. You can call this command programmatically and with the correct arguments disable or enable an NIC. This should work for all OSes.
I will leave it up to you to figure out how to call the command from code.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|