Aaron Thomas Aaron Thomas - 11 months ago 77
C# Question

How to Run a C# console application with the console hidden

Is there a way to hide the console window when executing a console application?

I am currently using a Windows Forms application to start a console process but I don't want the console window to be displayed while the task is running.

Answer Source

if you are using the ProcessStartInfo class you can set the window style to hidden.

System.Diagnostics.ProcessStartInfo start =
      new System.Diagnostics.ProcessStartInfo();     
start.FileName = dir + @"\Myprocesstostart.exe";
start.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;