【发布时间】:2011-01-13 18:25:29
【问题描述】:
我有一个模块需要运行一个小的 .Net 命令行程序来检查更新。一切都很好,但是我无法阻止显示命令提示符输出。
该应用有自己的 Windows 窗体,如果检测到更新,它会弹出。更新需要作为单独的应用程序运行,因为它需要与启动它的 DLL 不同的执行上下文。
string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\" + AUTO_UPDATE_EXENAME;
updater.StartInfo.FileName = path;
updater.StartInfo.Arguments = AUTO_UPDATE_PARAMETERS;
updater.StartInfo.CreateNoWindow = false;
updater.StartInfo.UseShellExecute = false;
updater.StartInfo.RedirectStandardOutput = true;
updater.StartInfo.WorkingDirectory = path;
updater.Start();
我已经尝试了 CreateNoWindow、UseShellExecute 和 RedirectStandardOutput 的所有不同工作组合,它们中的每一个都会导致那个烦人的黑框弹出。该应用确实会写入标准输出,但我仅将其用于调试,用户不应真正看到它生成的文本。
据说CreateNoWindow 和/或RedirectStandardOutput 应该防止弹出框,但不管我如何设置这些变量。
【问题讨论】:
-
哇,错过了那个。谢谢!
标签: c# .net process command-prompt