从隐藏窗口运行进程

时间:2013-04-01 14:03:14

标签: c# windows process

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

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

1 个答案:

答案 0 :(得分:0)

您可以尝试创建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");
}