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();