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.


如果您正在使用ProcessStartInfo类,则可以将窗口样式设置为隐藏:

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

If you wrote the console application you can make it hidden by default.

Create a new console app then then change the "Output Type" type to "Windows Application" (done in the project properties)


If you are using Process Class then you can write

yourprocess.StartInfo.UseShellExecute = false;
yourprocess.StartInfo.CreateNoWindow = true;

before yourprocess.start(); and process will be hidden

链接地址: http://www.djcxy.com/p/50566.html

上一篇: 我如何更新C#Windows控制台应用程序中的当前行?

下一篇: 如何在隐藏控制台的情况下运行C#控制台应用程序