System.Diagnostics.Process P = new System.Diagnostics.Process();
//P.StartInfo.RedirectStandardOutput = true;
P.StartInfo.CreateNoWindow = true;
P.StartInfo.WorkingDirectory = WorkingDirectory;
P.StartInfo.FileName = WorkingDirectory + "\\" + Myexe;
P.StartInfo.Arguments = cm[0];
P.EnableRaisingEvents = true;
P.StartInfo.UseShellExecute = false;
P.Exited += new EventHandler(captureStdout); // if you want to capture the output when the process exits
try
{
P.Start();
}
catch(Exception exProcess)
{
LogEvent(" Error in starting process: WorkingDirectory: " + WorkingDirectory + " Exe:" + Myexe + " Arguments: " + cm[0] + " " + exProcess.Message + "\r\n",false);
return;
}
private void captureStdout(object sender, EventArgs e)
{
System.Diagnostics.Process ps = (System.Diagnostics.Process) sender;
{
LogEvent(Myexe + " has ended. [" + DateTime.Now.ToString() + "]\r\n",false);
}