【问题标题】:Working a process in background在后台运行进程
【发布时间】:2023-03-10 18:44:01
【问题描述】:

我正在使用 C# 运行另一个 .exe 应用程序。

但是我想在后台运行 .exe 我尝试了 Start info hide 但没有帮助

我该怎么做?

目前这是我正在使用的代码

_p = new System.Diagnostics.Process();
_startInfro = new System.Diagnostics.ProcessStartInfo();
_startInfro.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;                       
_startInfro.FileName = tmp[0];
_startInfro.Arguments = deleteRangeCommand;
_p.StartInfo = _startInfro;
_p.Start();

【问题讨论】:

  • 你可以在这里找到你的问题的答案:.NET - WindowStyle = hidden vs. CreateNoWindow = true? - 如果它不是你的 exe 并且你不能实现额外的参数来隐藏进程,那么它可能不能做太多或者你需要使用一些的 Windows API 来实现这一点。 Anaways,当这些参数被哪个应用程序尊重时,您可以在那里阅读。

标签: c# c#-4.0


【解决方案1】:

由于我没有提供有关要启动哪个 .exe 的信息,因此我无法确定此答案。但是CreateNoWindow 属性看起来就像您需要的一样。

您还必须按照文档中的说明将UseShellExecute 属性设置为false。否则CreateNoWindow 的值将被忽略。

【讨论】:

  • 嗨,谢谢你的回答,但是我改变了我的代码,它仍然打开了没有帮助:(
  • _p = new System.Diagnostics.Process(); _startInfro = new System.Diagnostics.ProcessStartInfo(); _startInfro.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; _startInfro.UseShellExecute = false; _startInfro.CreateNoWindow = true;
猜你喜欢
  • 2021-04-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-05-30
  • 1970-01-01
  • 2011-07-14
相关资源
最近更新 更多