2,主要代码 private void btn1_Click(object sender, EventArgs e) { Process exeCommand = new Process(); exeCommand.StartInfo.FileName = "cmd"; exeCommand.StartInfo.RedirectStandardInput = true; exeCommand.StartInfo.RedirectStandardOutput
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);
}