即使在ProcessWindowStyle.Hidden之后,控制台窗口仍会弹出。 [英] Console window still popping up even after ProcessWindowStyle.Hidden;

查看:455
本文介绍了即使在ProcessWindowStyle.Hidden之后,控制台窗口仍会弹出。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须从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之后,控制台窗口仍会弹出。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆