gpt4 book ai didi

c# - 使用 .NET 从启动的命令行应用程序中抑制命令窗口

转载 作者:太空狗 更新时间:2023-10-30 00:36:21 25 4
gpt4 key购买 nike

我有一个模块需要运行一个小型 .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();

我已经尝试了 CreateNoWindowUseShellExecuteRedirectStandardOutput 的大部分不同工作组合,它们中的每一个都会导致令人讨厌的黑色框弹出。该应用确实会写入标准输出,但我仅将其用于调试,用户不应真正看到它生成的文本。

据推测,CreateNoWindow 和/或 RedirectStandardOutput 应该可以防止框弹出,但无论我如何设置这些变量,它都会起作用。

最佳答案

将命令行应用程序设置为 Winforms 应用程序,但不要像通常那样在执行时打开表单。

关于c# - 使用 .NET 从启动的命令行应用程序中抑制命令窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2211514/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com