Console window still popping up even after ProcessWindowStyle.Hidden;

爷,独闯天下 提交于 2019-11-28 08:01:31

问题


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();

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.

Thanks.


回答1:


Set the ProcessStartInfo.CreateNoWindow property to true



来源:https://stackoverflow.com/questions/3497924/console-window-still-popping-up-even-after-processwindowstyle-hidden

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!