Created
December 18, 2012 17:23
-
-
Save henriquegogo/4329963 to your computer and use it in GitHub Desktop.
A method to run shell command and return the command line return
This file contains hidden or 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
private static string RunShellCommand(string command) | |
{ | |
var arguments = "/C " + command; | |
var proccessSettings = new ProcessStartInfo("cmd.exe", arguments) | |
{ | |
WindowStyle = ProcessWindowStyle.Hidden, | |
RedirectStandardOutput = true, | |
UseShellExecute = false, | |
CreateNoWindow = true | |
}; | |
var proccess = Process.Start(proccessSettings); | |
var shellReturn = proccess.StandardOutput.ReadToEnd(); | |
proccess.WaitForExit(); | |
return shellReturn; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment