大家好:
C# 调用CMD.exe执行help命令程序卡住了,其他的命令没有问题上代码:
private void ExecuteCmd(string command)
{
Process p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.CreateNoWindow = true;
p.Start();
p.StandardInput.WriteLine(command);
p.StandardInput.WriteLine("exit");
p.WaitForExit();
this.textBox1.Text=textBox1.Text+ p.StandardOutput.ReadToEnd();
p.Close();
}
执行ipconfig,dir等都没有问题,就是执行help的时候程序卡住不动了,请问为什么?
C# 调用CMD.exe执行help命令程序卡住了,其他的命令没有问题上代码:
private void ExecuteCmd(string command)
{
Process p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.CreateNoWindow = true;
p.Start();
p.StandardInput.WriteLine(command);
p.StandardInput.WriteLine("exit");
p.WaitForExit();
this.textBox1.Text=textBox1.Text+ p.StandardOutput.ReadToEnd();
p.Close();
}
执行ipconfig,dir等都没有问题,就是执行help的时候程序卡住不动了,请问为什么?
去掉p.WaitForExit();之后我这里调试没问题
ExecuteCmd("help");