我有一个模块需要运行一个小的 .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
应该防止该框弹出,但无论我如何设置这些变量。