C#中執行Dos命令 C# 本來封裝了很多 類似於Dos命令的東西可是開發需要用它來執行 cmdtexe
static void Main(string[] args)
{ commandstartcmd(ping)commandcmdPross(ping )}
public static string cmdPross(string command string argument)
{ string output = try { Process cmd = new Process()
cmdStartInfoFileName = commandcmdStartInfoArguments = argument
cmdStartInfoUseShellExecute = false
cmdStartInfoRedirectStandardInput = truecmdStartInfoRedirectStandardOutput = true
cmdStartInfoCreateNoWindow = truecmdStartInfoWindowStyle = ProcessWindowStyleHidden
cmdStart()
output = cmdStandardOutputReadToEnd()ConsoleWriteLine(output)cmdWaitForExit()cmdClose()} catch (Exception e)
{ ConsoleWriteLine(e)} return output}
From:http://tw.wingwit.com/Article/program/net/201311/11984.html