I am trying to create a c# form with 2 buttons.
btn1 = disable LAN
btn2 = enable LAN
I have never done something on this level before.
What I want to accomplish is when I click on btn1 I want to disabled the LAN, and btn to enable it again.
This is what I am testing:
System.Diagnostics.Process.Start(ipconfig);
This runs, it runs the cmd and ipconfig I can actually see the IP display BUT...
This is the netsh command:
netsh interface set interface name="Local Area Connection" admin=DISABLED
If I run this via the console it works 100%
I want to use this command by clicking the button?
How do I go about getting this to work? Because I have tried this and does not work:
System.Diagnostics.Process.Start(netsh interface set interface name="Local Area Connection " admin=DISABLED);
any help?
This should work:
System.Diagnostics.Process.Start("netsh.exe", "whatever you would need to write as parameters");
For instance, for a mobile broadband connection, I would start this connection with:
System.Diagnostics.Process.Start("netsh.exe", "mbn connect interface=\"Mobile broadband\" connmode=name name=\"NAME OF CONNECTION\"");
In the above example, you would be able to find the name of the connection by finding the connection in your typical network manager (in Windows 8, it's in the right-side slide-in network overview thing). This part is not really relevant to your question, though, but others might be interested in it.