C# 从隐藏窗口运行进程

C# 从隐藏窗口运行进程,c#,windows,process,C#,Windows,Process,在尝试从隐藏窗口运行进程时,我遇到了一个奇怪的问题—我运行的进程与我的进程一样在隐藏窗口中运行,我是否做错了什么?我想运行不隐藏的子进程 Process.Start(Path.GetTempPath() + "cleanup.exe", Path.GetDirectoryName(Application.StartupPath); 您可以尝试创建Process类的对象,如下所示: Process objProcess = new Process(); objProces

在尝试从隐藏窗口运行进程时,我遇到了一个奇怪的问题—我运行的进程与我的进程一样在隐藏窗口中运行,我是否做错了什么?我想运行不隐藏的子进程

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

您可以尝试创建
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
PropertyNope,不起作用。另外,我正在尝试从服务运行此进程。您是否从服务执行此进程,并希望显示在前面?这样不可能,服务没有输出窗口