Created
February 28, 2018 16:39
-
-
Save Danielkaas94/61ba3937f8211319e6693ab01bbfa3cc to your computer and use it in GitHub Desktop.
ExecuteCMDCommand. strCommandToCMD is the command it can be something as "netsh wlan show networks"
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
private void ExecuteCMDCommand(string strCommandToCMD) | |
{ | |
Process cmd = new Process(); | |
cmd.StartInfo.FileName = "cmd.exe"; | |
cmd.StartInfo.RedirectStandardInput = true; | |
cmd.StartInfo.RedirectStandardOutput = true; | |
cmd.StartInfo.CreateNoWindow = true; | |
cmd.StartInfo.UseShellExecute = false; | |
cmd.Start(); | |
cmd.StandardInput.WriteLine(strCommandToCMD); | |
cmd.StandardInput.Flush(); | |
cmd.StandardInput.Close(); | |
cmd.WaitForExit(); | |
Console.WriteLine(cmd.StandardOutput.ReadToEnd()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment