0
我試圖運行explorer.exe使用Process.start(ProcessInfo);函數,然後等待進程自行終止,然後在進程退出時執行一些操作。 這裏是代碼snippestProcess.start啓動資源管理器,但瀏覽器仍在運行時將其hasexited屬性設置爲true
ProcessStartInfo StartInfo = new ProcessStartInfo();
StartInfo.FileName = "\\SDMMC\\explorer.exe";
StartInfo.UseShellExecute = false;
StartInfo.Arguments = null;
Process NewProcess = Process.Start(StartInfo);
NewProcess.WaitForExit();
NewProcess.EnableRaisingEvents = true;
NewProcess.Exited += new EventHandler(NewProcess_Exited);
MessageBox.Show("ExitCode finished");
但explorer.exe的仍在運行和在另一方面NewProcess.HasExited是真實的, 請幫助我如何可以使程序等待Explorer.exe的終止,然後perfom任何行動。 謝謝