如何通过调用cmd来运行特定的DOS命令?
- 内容介绍
- 文章标签
- 相关推荐
本文共计116个文字,预计阅读时间需要1分钟。
plaintext
2,主要代码:private void btn1_Click(object sender, EventArgs e) { Process exeCommand=new Process(); exeCommand.StartInfo.FileName=cmd; exeCommand.StartInfo.RedirectStandardInput=true; exeCommand.StartInfo.RedirectStandardOutput=true; }
2,主要代码
private void btn1_Click(object sender, EventArgs e){ Process exeCommand = new Process();
exeCommand.StartInfo.FileName = "cmd";
exeCommand.StartInfo.RedirectStandardInput = true;
exeCommand.StartInfo.RedirectStandardOutput = true;
exeCommand.StartInfo.CreateNoWindow = true;
exeCommand.StartInfo.UseShellExecute = false;
exeCommand.Start();
exeCommand.StandardInput.WriteLine(this.txtCommand.Text);
exeCommand.StandardInput.WriteLine("exit");
string info = exeCommand.StandardOutput.ReadToEnd();
this.txtMessage.AppendText(info);
}
本文共计116个文字,预计阅读时间需要1分钟。
plaintext
2,主要代码:private void btn1_Click(object sender, EventArgs e) { Process exeCommand=new Process(); exeCommand.StartInfo.FileName=cmd; exeCommand.StartInfo.RedirectStandardInput=true; exeCommand.StartInfo.RedirectStandardOutput=true; }
2,主要代码
private void btn1_Click(object sender, EventArgs e){ Process exeCommand = new Process();
exeCommand.StartInfo.FileName = "cmd";
exeCommand.StartInfo.RedirectStandardInput = true;
exeCommand.StartInfo.RedirectStandardOutput = true;
exeCommand.StartInfo.CreateNoWindow = true;
exeCommand.StartInfo.UseShellExecute = false;
exeCommand.Start();
exeCommand.StandardInput.WriteLine(this.txtCommand.Text);
exeCommand.StandardInput.WriteLine("exit");
string info = exeCommand.StandardOutput.ReadToEnd();
this.txtMessage.AppendText(info);
}

