标签:
System.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;// 不显示 cmd 窗口 proIP.Start(); proIP.StandardInput.WriteLine("ping www.baidu.com"); proIP.StandardInput.WriteLine("exit"); string strResult=proIP.StandardOutput.ReadToEnd(); if (strResult.IndexOf("(0% 丢失)") != -1 || strResult.IndexOf("(0% loss)") != -1) Response.Write("<script>alert(‘Ping 通了!‘)</script>"); else if (strResult.IndexOf("(100% 丢失)") != -1 || strResult.IndexOf("(100% loss)") != -1) Response.Write("<script>alert(‘ 无法 Ping 通!‘)</script>"); else Response.Write("<script>alert(‘数据有丢失!‘)</script>"); proIP.Close();
标签:
原文地址:http://www.cnblogs.com/123fang/p/5950045.html