Skip to content

Instantly share code, notes, and snippets.

@henriquegogo
Created December 18, 2012 17:23
Show Gist options
  • Save henriquegogo/4329963 to your computer and use it in GitHub Desktop.
Save henriquegogo/4329963 to your computer and use it in GitHub Desktop.
A method to run shell command and return the command line return
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