-1

How can I get rid of the console window? I have the ProcessStartInfo as below

   var processStartInfo = new ProcessStartInfo()
    {
       FileName = Path.Combine(path, "Hi.exe");,
       WindowStyle = ProcessWindowStyle.Hidden,
       UseShellExecute = false,
       CreateNoWindow = true,
        RedirectStandardInput = true,
     };
      Process.Start(processStartInfo).StandardInput.WriteLine(argHandlerArgs);
user173092
  • 127
  • 1
  • 1
  • 9
  • `processStartInfo.CreateNoWindow = true` – Jimi May 27 '20 at 23:12
  • It is already set to true – user173092 May 27 '20 at 23:32
  • 1
    Yes, sorry, that thing I was writing on got to my nerves. I mean, if that `Hi.exe` is a Console app, use just `CreateNoWindow = true`, remove `WindowStyle` so it won't get in the way and add `.RedirectStandardError = True`. – Jimi May 27 '20 at 23:40
  • That didn't work either – user173092 May 28 '20 at 19:52
  • 1
    You're doing something wrong (your code here won't compile). See the sample code here: [How do I get output from a command to appear in a control on a Form in real-time?](https://stackoverflow.com/a/51682585/7444103), take it as it is and try again. I'm not saying that it will work for you - I don't know what your Console app is doing (or what you're doing) - but it usually does :) – Jimi May 28 '20 at 20:01

1 Answers1

0

Why the console window shown even if i set it to be hidden?

As per the docs:

To use Hidden, the UseShellExecute property must be true.

But you have set UseShellExecute to be false.

If your process is short running, consider using Minimized instead.

mjwills
  • 23,389
  • 6
  • 40
  • 63