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}