Last active
February 9, 2018 15:26
-
-
Save anytizer/bed804209b0615b1973817b7d5ea8e37 to your computer and use it in GitHub Desktop.
Command line execution and output in C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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