从隐藏窗口运行进程

本文关键字:进程 运行 窗口 隐藏 | 更新日期: 2023-09-27 18:06:44

当试图从隐藏窗口运行进程时,我遇到了一个奇怪的问题-我运行的进程像我的进程一样隐藏运行,我做错了什么吗?我想运行未隐藏的子进程

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");
}