记录一下
Process cmdProcess = new Process(); cmdProcess.StartInfo.FileName = "cmd.exe"; cmdProcess.StartInfo.RedirectStandardInput = true;//是否可以输入 cmdProcess.StartInfo.RedirectStandardOutput = true;//是否可以输出 cmdProcess.StartInfo.CreateNoWindow = true; cmdProcess.Start();//执行 cmdProcess.StandardInput.WriteLine(cmdString); //向cmd窗口发送输入信息 cmdProcess.StandardInput.WriteLine("&exit");//要退出 cmdProcess.StandardInput.AutoFlush = true; //提交 string results = cmdProcess.StandardOutput.ReadToEnd();//输出 cmdProcess.WaitForExit();//等待程序执行完退出进程 cmdProcess.Close();//结束
标签:WriteLine,C#,cmd,StandardInput,命令行,StartInfo,true,cmdProcess From: https://www.cnblogs.com/cvol/p/16665265.html