cancel
Showing results for 
Search instead for 
Did you mean: 

Running Process from command prompt and capturing output and error

AnushaSomasund2
Level 2
Hi Team, In my current project client want to run the processes from command prompt and capture the output whether the process is initiated successfully or not. PFB the code for doing the same.  System.Diagnostics.ProcessStartInfo startInfo =         new System.Diagnostics.ProcessStartInfo("CMD.exe"); System.Diagnostics.Process p = new System.Diagnostics.Process(); startInfo.RedirectStandardInput = true; startInfo.UseShellExecute = false; startInfo.RedirectStandardOutput = true; startInfo.RedirectStandardError = true; p = System.Diagnostics.Process.Start(startInfo); //p.StandardInput.WriteLine(@"Echo on"); //p.StandardInput.WriteLine(@"dir " + @"C:"); p.StandardInput.WriteLine(@"chdir " + @"C:\Program Files\Blue Prism Limited\Blue Prism Automate "); p.StandardInput.WriteLine(@"AutomateC /run ""Sample process"" /resource /sso"); p.StandardInput.WriteLine(@"EXIT");  result = p.StandardOutput.ReadToEnd();  error = p.StandardError.ReadToEnd();  
0 REPLIES 0