المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : How to know application exit in Console started by Process.Start("cmd.exe"))



C# Programming
03-02-2012, 06:53 AM
How can the program know the application has ended in comman line console started by System.ServiceProcess.Process.Start("cmd.exe")?
The c# code is as follows:

using System.ServiceProcess; Process proc = new Process(); proc.StartInfo.FileName = "cmd.exe"; // to use command-line proc.StartInfo.RedirectStandardInput = true; proc.StartInfo.RedirectStandardOutput = true; proc.StartInfo.UseShellExecute = false; proc.StartInfo.CreateNoWindow = true; proc.Start(); // start the command line console (invisible) //application.exe is command-line application program // it has to to be run in command line console proc.StandardInput.WriteLine("application.exe"); // how can I know the external application.exe has ended // so that the program can proceed based on the result of // the application execution. // proc.Close();
I appreciate your help.
Sheng