【问题标题】:Running process from hidden window从隐藏窗口运行进程
【发布时间】:2013-04-01 14:03:13
【问题描述】:

我在尝试从隐藏窗口运行进程时遇到了一个奇怪的问题 - 我运行的进程像我的进程一样在隐藏中运行,我做错了什么吗?我想运行那个不隐藏的子进程。

Process.Start(Path.GetTempPath() + "cleanup.exe", Path.GetDirectoryName(Application.StartupPath);

【问题讨论】:

  • 出现了什么奇怪的问题?

标签: c# windows process


【解决方案1】:

您可以尝试创建Process 类的对象,如下所示:

Process objProcess = new Process();            
objProcess.StartInfo.UseShellExecute = false;
objProcess.StartInfo.RedirectStandardOutput = true;
objProcess.StartInfo.CreateNoWindow = true;
objProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;

// Passing the batch file/exe name
objProcess.StartInfo.FileName = string.Format(strBatchFileName);

// Passing the argument
objProcess.StartInfo.Arguments = string.Format(strArgument);
try
{
 objProcess.Start();
}
catch
{
 throw new Exception("Batch file is not found for processing");
}

【讨论】:

  • 我想运行那个不隐藏的子进程。
  • 然后你可以更改WindowStyle属性
  • 不,没用。另外,我正在尝试从服务中运行此进程。
  • 您是从服务中执行此过程并希望显示在前面吗?
  • 这样不行,服务没有输出窗口
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-10-21
  • 1970-01-01
  • 1970-01-01
  • 2015-10-04
  • 2012-05-10
相关资源
最近更新 更多