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