I have to execute a '.exe' file which produces a output and asks for another input again. I am able to run the first part but I am not able to pass the second parameter to complete the process.
Here is my code:
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = @"C:\Context.exe";
startInfo.Arguments = "xyz";
startInfo.UseShellExecute = false;
startInfo.CreateNoWindow = true;
Process.Start(startInfo);
I would use StandardInput in conjunction with RedirectStandardInput. You can pass any data that a user would enter on the command line using this StandardInput StreamWriter object. If this application has a user interface, you may need to do something else entirely.
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = @"C:\Context.exe";
startInfo.Arguments = "xyz";
startInfo.UseShellExecute = false;
startInfo.CreateNoWindow = true;
startInfo.RedirectStandardInput = true;
var p = Process.Start(startInfo);
// Write whatever data you need to send to the application here.
p.StandardInput.Write("y");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With