Page 1 of 1

How to Connect/Disconnect Internet through c# code

Posted: Fri Jul 26, 2013 11:30 am
by AutomationTester
Dear support team,

How to Connect/Disconnect Internet through c# code? . In Command Prompt, we use 'ipconfig/release' for disconnect and 'ipconfig/renew' for connect. urgent help needed.

Regards,
Amiruddin

Re: How to Connect/Disconnect Internet through c# code

Posted: Fri Jul 26, 2013 3:32 pm
by Ciege
This is a general C# question that you should be able to find by doing a quick Google search...

Something like this should work. I just typed it up real quick so there might be a bug but it should get you going...

Code: Select all

ProcessStartInfo pInfo = new ProcessStartInfo();
pInfo.FileName = @"C:\WINDOWS\System32\ipconfig.exe";
pInfo.Arguments = "/release";
Process p = Process.Start(pInfo);
p.WaitForExit();

Re: How to Connect/Disconnect Internet through c# code

Posted: Mon Jul 29, 2013 5:54 am
by AutomationTester
Hai Ciege,

The code you sent is working perfectly.

Thanks
Amiruddin