解决方案 »

  1.   

    手动执行你的cmd命令看看有没有什么问题,如果没问题就是你的代码有问题,单步调试一下。
      

  2.   


    CMD命令是没有问题的,可以换成ipconfig ,代码是有问题,但是不知道问题在哪!能编译成功,执行完后winform窗口就挂了
      

  3.   

    我上网查了一下,可能你与这个问题类似,也就是说要在p.StandardInput.WriteLine("svscmd");//执行DOS命令 后面加上p.StandardInput.Close(); 然后才能阻止标准输入流所谓的deadlock或者说是hangs。参考:http://www.codeproject.com/Questions/74521/StandardOutput-ReadLine-FreezesDeadlocks are a common issue when working with RedirectStandardInput & Output. The way to avoid this is to close the RedirectIO. In your example you already flushed it but did not close it.
      

  4.   


                p.StandardInput.WriteLine("exit");
                p.BeginOutputReadLine();
                p.StandardOutput.ReadToEnd();
    按照你的方法,把这三句话注释掉,果然有效,多谢啊!