Process myProcess = new Process();
myProcess.StartInfo.FileName = "cmd.exe";//启动cmd命令
myProcess.StartInfo.UseShellExecute = false;//是否使用系统外壳程序启动进程
myProcess.StartInfo.RedirectStandardInput = true;//是否从流中读取
myProcess.StartInfo.RedirectStandardOutput = true;//是否写入流
myProcess.StartInfo.RedirectStandardError = true;//是否将错误信息写入流
myProcess.StartInfo.CreateNoWindow = true;//是否在新窗口中启动进程
//myProcess.Exited += new EventHandler(myProcess_Exited);
myProcess.Start();//启动进程
//myProcess.StandardInput.WriteLine("dir" + "&exit");
myProcess.StandardInput.WriteLine("netsh wlan delete profile name=\"wwwwwww\"" + " &exit");//执行命令
myProcess.StandardInput.AutoFlush = true;
string output = myProcess.StandardOutput.ReadToEnd();
textBox1.AppendText(output);
myProcess.WaitForExit();
myProcess.Close();
C# 启动CMD
猜你喜欢
转载自blog.csdn.net/chscomfaner/article/details/82785038
今日推荐
周排行