我必须从Windows应用程序中运行控制台应用程序。我要运行的控制台应用程序是我应用程序中的嵌入式资源,我这样称呼它:
I have to run a console application from my Windows Application. The console application I want to run is an Embedded Resource in my application, and I am calling it like this:
// Run the updater and grab its output Process Updater = new Process(); Updater.StartInfo.FileName = "C:\\tmp\\tmp.exe"; Updater.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; Updater.StartInfo.UseShellExecute = false; Updater.StartInfo.RedirectStandardOutput = true; Updater.Start(); string UpdaterOutput = Updater.StandardOutput.ReadToEnd(); Updater.WaitForExit();它提取得很好,它运行得很好,而且它的输出也非常好...但是我仍然可以看到控制台窗口在运行时迅速弹出。我知道控制台是从此应用程序弹出的,因为控制台标题为 C:\tmp\tmp.exe 。有什么完全失败的方法可以隐藏控制台应用程序?我认为使用 ProcessWindowStyle.Hidden 可以做到,但显然不能。
It extracts fine, and it runs fine, and it also grabs its output completely fine... but I can still see the console Window popping open quickly as it's run. I know the console pop up is from this application because the console title is C:\tmp\tmp.exe. Is there any completely fail proof way to hide the console application? I thought using ProcessWindowStyle.Hidden would do it but apparently not.
谢谢。
推荐答案设置 ProcessStartInfo.CreateNoWindow 属性设置为 true
更多推荐
即使在ProcessWindowStyle.Hidden之后,控制台窗口仍会弹出。
发布评论