473,408 Members | 2,888 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Network Devices

Is there a way to enable and disable a network card Present in my computer..

Thanks
Rajkiran
Dec 13 '07 #1
1 1903
Rajkiran, you could launch ipconfig.exe via System.Diagnostics.Process
class. The easy way is using the Form Designer - dropping a Toolbox Process
icon onto a form and setting up process properties and the Exit event (you
may want to know when the process finished). The generated code would look
like this:

private System.Diagnostics.Process process1;

this.process1 = new System.Diagnostics.Process();

this.process1.EnableRaisingEvents = true;

this.process1.StartInfo.CreateNoWindow = true;

this.process1.StartInfo.Domain = "";

this.process1.StartInfo.FileName = "ipconfig.exe";

this.process1.StartInfo.LoadUserProfile = false;

this.process1.StartInfo.Password = null;

this.process1.StartInfo.RedirectStandardOutput = true;

this.process1.StartInfo.StandardErrorEncoding = null;

this.process1.StartInfo.StandardOutputEncoding = null;

this.process1.StartInfo.UserName = "";

this.process1.StartInfo.UseShellExecute = false;

this.process1.SynchronizingObject = this;

this.process1.Exited += new System.EventHandler(this.OnProcessExited);

//add code for Exited EventHandler

private void OnProcessExited(object sender, EventArgs e)

{

process1.Close();

//add code for visual feedback

}

to disable Network Interfaces place a call

private void ReleaseNetworkInterfaces()

{

process1.StartInfo.Arguments = "/release";

process1.Start();

}

to restore:

private void RenewNetworkInterfaces()

{

process1.StartInfo.Arguments = "/renew";

process1.Start();

}

I am not sure this is the best way, but it certainly works. You could take
it a step further and add events notifying when the network connection is
restored (IPAddress acquired).

Michael
"Rajkiran R.B." <ra*********@hotmail.comwrote in message
news:E1**********************************@microsof t.com...
Is there a way to enable and disable a network card Present in my
computer..

Thanks
Rajkiran


Dec 13 '07 #2

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

Similar topics

3
by: Scott Leonard | last post by:
Hello - I'm writing an application that will be used on "sometimes connected" devices (laptops, tablets). In C#, what is the best way to detect whether a network connection is present? I'd...
7
by: Joe Ross | last post by:
I've been working with Microsoft support for over 3 weeks now on an intermittent General Network Error we're seeing in our production environment between our ASP.NET application and SQL Server...
0
by: chaks.yoper | last post by:
hi all, i would like to know whether python can help me querying the network devices attached to my system (ethernet,wireless) and display their module name and vendor name? thank you. ...
3
by: stacy | last post by:
I am developing an application that must look out over TCP on an ethernet connection to locate our proprietary devices. The Web application and the devices are communicating over ethernet with...
31
by: damacy | last post by:
hi, there. i have a problem writing a program which can obtain ip addresses of machines running in the same local network. say, there are 4 machines present in the network; , , and and if i...
2
by: =?Utf-8?B?Um9ja3k=?= | last post by:
If the network cable is unplugged I need to change an image on my main form status bar, however this does not work ' The computer has been connected or disconnected from the network If...
2
by: Folkien | last post by:
Hello everybody. I want to make a little programme to show the network availability status. I read that I had to use Microsoft.VisualBasic.Devices, creat a delegate to manage the event. Here...
1
by: 33223 | last post by:
Local Area Network (LAN) Both an EtherNet (wire) network and a wireless network are referred to as a Local Area Network (LAN). A wireless network does not require hubs, switchers, or routers to...
3
by: Studlyami | last post by:
I was connected remotely into one of my pc's and i ran the windows network wizard to allow me to share files on my home network. As soon as i finished the wizard my remote connection broke. I went...
1
by: yawesome | last post by:
I am using Microsoft.VisualBasic.Devices.Network to download a file from a server to a PC and am receiving a 404 error. The file is in teh download location but it has 0kb. Does anyone have any...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...

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.