How to Connect/Disconnect Internet through c# code

Ask general questions here.
AutomationTester
Posts: 30
Joined: Mon Jan 21, 2013 1:31 pm

How to Connect/Disconnect Internet through c# code

Post by AutomationTester » Fri Jul 26, 2013 11:30 am

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

User avatar
Ciege
Posts: 1336
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

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

Post by Ciege » Fri Jul 26, 2013 3:32 pm

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();
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

AutomationTester
Posts: 30
Joined: Mon Jan 21, 2013 1:31 pm

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

Post by AutomationTester » Mon Jul 29, 2013 5:54 am

Hai Ciege,

The code you sent is working perfectly.

Thanks
Amiruddin