Skip to content

Instantly share code, notes, and snippets.

@anytizer
Last active February 9, 2018 15:26
Show Gist options
  • Save anytizer/bed804209b0615b1973817b7d5ea8e37 to your computer and use it in GitHub Desktop.
Save anytizer/bed804209b0615b1973817b7d5ea8e37 to your computer and use it in GitHub Desktop.
Command line execution and output in C#
string args = "-f edit.php";
string file = "php.exe";
ProcessStartInfo info = new ProcessStartInfo();
info.FileName = file;
info.Arguments = args;
info.RedirectStandardOutput = true;
info.RedirectStandardError = true;
info.UseShellExecute = false;
info.CreateNoWindow = true; // flashing screen hidden
Process process = new Process();
process.StartInfo = info;
process.EnableRaisingEvents = true;
process.Start();
//process.WaitForExit(); // often crashes
string output = process.StandardOutput.ReadToEnd();
return output;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment