That didn't work for me. It returned an error along the lines of path not found. I know however that the path does exist because the code below is a way a friend showed me just recently which I've implemented and which does work. Assume for this that processPath is a string which contains the process path.
This is a more generic version of the code I'm using in case another has the same issue as me. I hope this helps.
Code:
string returnvalue = "";
// Starts the new process as command prompt
ProcessStartInfo info = new ProcessStartInfo("cmd.exe");
info.UseShellExecute = false;
info.RedirectStandardInput = true;
info.RedirectStandardOutput = true;
// Makes it so the command prompt window does appear
info.CreateNoWindow = true;
using (Process process = Process.Start(info))
{
StreamWriter sw = process.StandardInput;
StreamReader sr = process.StandardOutput;
// This for loop could be used if you had a string[] commands where each string in commands
// is it's own command to write to the prompt. I chose to hardcode mine in.
//foreach (string command in commands)
//{
// sw.WriteLine(command);
//}
sw.WriteLine("cd " + processPath);
sw.WriteLine("perl process.pl");
sw.Close();
returnvalue = sr.ReadToEnd();
}
return returnvalue;