如何运行与隐藏的控制台的C#控制台应用程序
问题描述:
执行控制台应用程序时,有没有一种方法来隐藏控制台窗口?
Is there a way to hide the console window when executing a console application?
我目前使用Windows窗体应用程序启动控制台进程,但我不希望任务运行时要显示的控制台窗口。
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
类,你可以将窗口样式设置为隐藏。
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;