当前位置:首页 > 服务器端Web控件与客户端Html控件交互(转)
动和停止本地系统进程操作 11 //设定必要属性
12 p.StartInfo.FileName = \13 p.StartInfo.UseShellExecute = false;
14 p.StartInfo.RedirectStandardInput = true;//介于CMD输入 15 p.StartInfo.RedirectStandardOutput = true;//基于CMD输出 16 p.StartInfo.RedirectStandardError = true;//
17 p.StartInfo.CreateNoWindow = true;//是否创建窗口 18
19 string pingrst;
20 p.Start();//开始执行Process 21
22 p.StandardInput.WriteLine(\23 p.StandardInput.WriteLine(\
24 string strRst = p.StandardOutput.ReadToEnd(); 25
26 //获取ping返回的状态值
27 if (strRst.IndexOf(\28 pingrst = \连接\
29 else if (strRst.IndexOf(\30 pingrst = \无法到达目的主机\
31 else if (strRst.IndexOf(\32 pingrst = \超时\
33 else if (strRst.IndexOf(\34 pingrst = \无法解析主机\35 else
36 pingrst = strRst; 37
38 p.Close();//Prcess 最后注意关闭 39
40 return pingrst;//返回ping后结果 41 }
共分享92篇相关文档