user3859999 user3859999 - 4 months ago 33
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);


Make user shell execution false

proc.StartInfo.UseShellExecute = false;

and pass true in showWindow parameter

ExecuteApplication("netsh.exe","",cmd, true);