Process myProcess = new Process();
myProcess.StartInfo.CreateNoWindow = true;
myProcess.Start("net","192.168.0.1 -t");

解决方案 »

  1.   

    try thisSystem.Diagnostics.Process proIP=new System.Diagnostics.Process();
    proIP.StartInfo.FileName="cmd.exe";
    proIP.StartInfo.UseShellExecute = false;
    proIP.StartInfo.RedirectStandardInput = true;
    proIP.StartInfo.RedirectStandardOutput = true;
    proIP.StartInfo.RedirectStandardError = true;
    proIP.StartInfo.CreateNoWindow = true;
    proIP.Start();
    proIP.StandardInput.WriteLine("ping "+this.txtIP.Text.Trim());
    proIP.StandardInput.WriteLine("exit");
    string strResult=proIP.StandardOutput.ReadToEnd();
    if(strResult.IndexOf("(0% loss)")!=-1)
    this.txtShow.Text="Ping 通了!";
    else if(strResult.IndexOf("(100% loss)")!=-1)
    this.txtShow.Text="无法 Ping 通!";
    else
    this.txtShow.Text="数据有丢失!";
    proIP.Close();
      

  2.   

    和yistudio(绿荫) 一样,但直接运行ping.exeSystem.Diagnostics.Process proIP=new System.Diagnostics.Process();
    proIP.StartInfo.FileName=@"C:\WINDOWS\system32\ping.exe";
    proIP.StartInfo.Arguments="127.0.0.1";
    proIP.StartInfo.UseShellExecute = false;
    proIP.StartInfo.RedirectStandardInput = false;
    proIP.StartInfo.RedirectStandardOutput = true;
    proIP.StartInfo.RedirectStandardError = true;
    proIP.StartInfo.CreateNoWindow = true;
    proIP.Start(); do
    {
    string strResult=proIP.StandardOutput.ReadLine ();
    this.textBox1.Text +=strResult;
    this.textBox1.Refresh ();
    }while (!proIP.HasExited);

    proIP.Close();
      

  3.   

    http://dotnet.aspx.cc/ShowDetail.aspx?id=VXMGWMHF-OJCC-4RBD-KH6X-RIJQLD17QMFW