Process prc=new Process();
prc.StartInfo.FileName="cmd.exe";
prc.StartInfo.UseShellExecute=false;
prc.StartInfo.RedirectStandardInput = true;
prc.StartInfo.RedirectStandardOutput = true;
prc.StartInfo.RedirectStandardError = true;
// prc.StartInfo.CreateNoWindow = true;
prc.Start();
prc.StandardInput.WriteLine("ping 10.1.0.1");
prc.StandardInput.WriteLine("exit");
prc.StandardInput.Close();
prc.StandardOutput.ReadToEnd();
我这样写什么信息都看不到,也不知道程序到底运行了没有
prc.StartInfo.FileName="cmd.exe";
prc.StartInfo.UseShellExecute=false;
prc.StartInfo.RedirectStandardInput = true;
prc.StartInfo.RedirectStandardOutput = true;
prc.StartInfo.RedirectStandardError = true;
// prc.StartInfo.CreateNoWindow = true;
prc.Start();
prc.StandardInput.WriteLine("ping 10.1.0.1");
prc.StandardInput.WriteLine("exit");
prc.StandardInput.Close();
prc.StandardOutput.ReadToEnd();
我这样写什么信息都看不到,也不知道程序到底运行了没有
解决方案 »
- .net页面如何根据坐标加载谷歌地图?
- 超过字段长度限制的长内容新闻用什么方法来保存
- 怎么实现点击DropDownList弹出Calendar然后选定日期给这个功能这个功能!在线等待,急!
- 数据层,引用CS文件
- eWebEditor编辑器的.net例子,哪为大哥发个个我([email protected])
- web应用程序发布的时候如何将前台代码编译在DLL里面
- 在上海,象我这样的一个月能拿多少钱??(临行前的调查,哥们们多多指教阿)
- Sql Server 中的text型字段,如何判断它为空?
- 为什么datareader不能直接读取字段的值,而要转换成字符串?
- 你们好吗
- ASP.Net占很大的内存,不知道是不是被攻击!
- ■■■想制作一个制作chm帮助文件的工具,给点思路,谢谢
prc.StartInfo.FileName="cmd.exe";
prc.StartInfo.UseShellExecute=false;
prc.StartInfo.RedirectStandardInput = true;
prc.StartInfo.RedirectStandardOutput = true;
prc.StartInfo.RedirectStandardError = true;
prc.StartInfo.CreateNoWindow = false;
prc.Start();
prc.StandardInput.WriteLine("ping 127.0.0.1");
prc.StandardInput.Close();
Response.Write(prc.StandardOutput.ReadToEnd());
string sql="select eqname,addr,ip from eq order by eqid desc";
DataTable dt=universal.sd.rdTable(sql);
DataColumn fullTitle = new DataColumn("rst");
fullTitle.DataType=System.Type.GetType("System.String");
dt.Columns.Add(fullTitle);
string strRst;
foreach(DataRow dr in dt.Rows)
{
Process prc=new Process();
prc.StartInfo.FileName="cmd.exe";
prc.StartInfo.UseShellExecute=false;
prc.StartInfo.RedirectStandardInput = true;
prc.StartInfo.RedirectStandardOutput = true;
prc.StartInfo.RedirectStandardError = true;
prc.StartInfo.CreateNoWindow = true;
prc.Start();
prc.StandardInput.WriteLine("ping -n 1 "+dr["ip"].ToString());
prc.StandardInput.WriteLine("exit");
strRst=prc.StandardOutput.ReadToEnd();
if(strRst.IndexOf("(0% loss)")!=-1) strRst = "连接"; else if( strRst.IndexOf("Destination host unreachable.")!=-1) strRst = "无法到达目的主机"; else if(strRst.IndexOf("Request timed out.")!=-1) strRst = "超时"; else if(strRst.IndexOf("Unknown host")!=-1) strRst = "无法解析主机";
prc.Close();
dr["rst"]=strRst;
}
dt.AcceptChanges();
dg.DataSource=dt;
dg.DataBind();
you didn't write the output out, how do you know what happend?? Process prc=new Process();
prc.StartInfo.FileName="cmd.exe";
prc.StartInfo.UseShellExecute=false;
prc.StartInfo.RedirectStandardInput = true;
prc.StartInfo.RedirectStandardOutput = true;
prc.StartInfo.RedirectStandardError = true;
prc.StartInfo.CreateNoWindow = false;
prc.Start();
prc.StandardInput.WriteLine("ping 127.0.0.1");
prc.StandardInput.Close();
Response.Write(prc.StandardOutput.ReadToEnd());
如果要执行关机,是否能把ping 127.0.0.1改成shutdown -s呢?