3
我正在做一個程序,我需要啓動cmd並啓動一個批處理文件。問題是我使用MyProcess.WaithForexit();
,我認爲它不會等到批處理文件處理完成。它只是等到cmd關閉。我的代碼到目前爲止:如何等到我的批處理文件完成
System.Diagnostics.ProcessStartInfo ProcStartInfo =
new System.Diagnostics.ProcessStartInfo("cmd");
ProcStartInfo.RedirectStandardOutput = true;
ProcStartInfo.UseShellExecute = false;
ProcStartInfo.CreateNoWindow = false;
ProcStartInfo.RedirectStandardError = true;
System.Diagnostics.Process MyProcess = new System.Diagnostics.Process();
ProcStartInfo.Arguments = "/c start batch.bat ";
MyProcess.StartInfo = ProcStartInfo;
MyProcess.Start();
MyProcess.WaitForExit();
我需要等到批處理文件完成。我怎麼做?
'start'啓動批處理並返回。刪除'開始'。 – CodeCaster