Basically I\'m running some performance tests and don\'t want the external network to be the drag factor. I\'m looking into ways of disabling network LAN. What is an effecti
I modfied the best voted solution from Kamrul Hasan to one methode and added to wait for the exit of the process, cause my Unit Test code run faster than the process disable the connection.
private void Enable_LocalAreaConection(bool isEnable = true)
{
var interfaceName = "Local Area Connection";
string control;
if (isEnable)
control = "enable";
else
control = "disable";
System.Diagnostics.ProcessStartInfo psi =
new System.Diagnostics.ProcessStartInfo("netsh", "interface set interface \"" + interfaceName + "\" " + control);
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo = psi;
p.Start();
p.WaitForExit();
}