I have a ruby script which I am trying to execute using Process from my program. After certain event, I want to stop its execution. I tried sending the ctrl + c using the solution provided in the quetsion How do I send ctrl+c to a process in c#? however its not working for me. Can anyone provide better solution? Below is the code:
string command = @"/c ruby C:\MyRubyProgram GetThis GetThat";
ProcessStartInfo start_info = new ProcessStartInfo("cmd", command);
start_info.UseShellExecute = false;
start_info.RedirectStandardOutput = true;
start_info.RedirectStandardInput=true;
Process process = new Process();
process.StartInfo = start_info;
process.Start();
process.WaitForExit();
process.StandardInput.WriteLine("\x3");
process.StandardInput.Close();
Console.Write(process.StandardOutput.ReadToEnd());