像这样的问题 你直接百度也就出来了` 
调用它的exit 退出控制台

解决方案 »

  1.   

     p.StandardInput.WriteLine("exit");  我已经调用了
      

  2.   


    static void Main(string[] args)
            {
                string ip = "202.114.187.23";
                string strRst = CmdPing(ip);            Console.WriteLine(strRst);
            }        private static string CmdPing(string strIp)
            {            Process p = new Process();            p.StartInfo.FileName = "ping.exe";            p.StartInfo.UseShellExecute = false;            p.StartInfo.RedirectStandardInput = true;            p.StartInfo.RedirectStandardOutput = true;            p.StartInfo.RedirectStandardError = true;            p.StartInfo.CreateNoWindow = true;
                p.StartInfo.Arguments = strIp;            string pingrst;            p.Start();            pingrst = p.StandardOutput.ReadToEnd();
                p.Close();            return pingrst;        }  为什么要调用cmd? 直接用ping不就得了?
      

  3.   

    谢谢4楼的哈 
    不过
    我把你代码完全复制过来。运行还是好多进程ping.exe,而且过一会输入的都是空格。没有内容 ,ping.exe进程也全没了   
      

  4.   

    pingrst = p.StandardOutput.ReadToEnd();  
    p.WaitForExit();
    p.Close(); 
      

  5.   

    System.Net.NetworkInformation命名空间下的Ping类,对Ping功能提供了直接支持。不必使用Process类进行外部命令调用。