我知道这个问题之前已经被问过,我之前已经尝试过这些帖子中给出的所有解决方案,但我似乎无法让它发挥作用:-
static void CallBatch(string path)
{
int ExitCode;
Process myProcess;
ProcessStartInfo ProcessInfo;
ProcessInfo = new ProcessStartInfo("cmd.exe", "/c " + path);
ProcessInfo.CreateNoWindow = true;
ProcessInfo.UseShellExecute = true;
myProcess = Process.Start(ProcessInfo);
myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
myProcess.WaitForExit();
myProcess.EnableRaisingEvents = true;
myProcess.Exited += new EventHandler(process_Exited);
ExitCode = myProcess.ExitCode;
Console.WriteLine("ExitCode: " + ExitCode.ToString(), "ExecuteCommand");
myProcess.Close();
}
当我尝试调用批处理文件时,即使 createNoWindow 和 UseShellExecute 都设置为 true,它仍然显示窗口。
我应该放点别的东西让它静默运行批处理文件吗?