user3859999 user3859999 - 1 year ago 108
C# Question

Run a Process silently in background without any window

I want to run NETSH command silently (with no window).
I wrote this code but it does not work.

public static bool ExecuteApplication(string Address, string workingDir, string arguments, bool showWindow)
Process proc = new Process();
proc.StartInfo.FileName = Address;
proc.StartInfo.WorkingDirectory = workingDir;
proc.StartInfo.Arguments = arguments;
proc.StartInfo.CreateNoWindow = showWindow;
return proc.Start();

string cmd= "interface set interface name=\"" + InterfaceName+"\" admin=enable";
ExecuteApplication("netsh.exe","",cmd, false);

Answer Source

Make user shell execution false

proc.StartInfo.UseShellExecute = false;

and pass true in showWindow parameter

ExecuteApplication("netsh.exe","",cmd, true);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download