You can say that the process does not use a window or minimizes it:
// don't execute on shell p.StartInfo.UseShellExecute = false; p.StartInfo.CreateNoWindow = true; // don't show window p.StartInfo.WindowStyle = ProcessWindowStyle.Minimized;
with UseShellExecute = false you can redirect the output:
// redirect standard output as well as errors p.StartInfo.RedirectStandardOutput = true; p.StartInfo.RedirectStandardError = true;
When you do this, you should use asynchronous reading of the output buffers to avoid a deadlock due to overflowing buffers:
StringBuilder outputString = new StringBuilder(); StringBuilder errorString = new StringBuilder(); p.OutputDataReceived += (sender, e) => { if (e.Data != null) { outputString.AppendLine("Info " + e.Data); } }; p.ErrorDataReceived += (sender, e) => { if (e.Data != null) { errorString.AppendLine("EEEE " + e.Data); } };
source share