c#.net怎么调用已打开的命令行窗口 我是要用程序获取到这个cmd窗口,然后读取窗口中的文本 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 System.Diagnostics.Process p = new System.Diagnostics.Process(); p.StartInfo.FileName="cmd.exe"; p.StartInfo.UseShellExecute=false; p.StartInfo.RedirectStandardError=true; p.StartInfo.RedirectStandardInput=true; p.StartInfo.RedirectStandardOutput=true; p.StartInfo.CreateNoWindow=true; //不显示命令行窗口 p.Start(); p.StandardInput.WriteLine("ping 127.0.0.1"); //输入要运行的命令 p.StandardInput.WriteLine("exit"); string strRst=p.StandardOutput.ReadToEnd(); //取得输出结果 如果是程序外打开的命令行窗口,则需要用PInvoke的方式调用Windows API. 先用Spy++捕捉窗口的信息.查找API在.NET中可用的形式, 可以到www.pinvoke.net. TcpClient类能异步构造吗? 请教一个关于Combobox的问题,谢谢!!! 俄文编码的问题 关于webbrowser 如何取得有汉字的网址 数据传递 (100分)求C#打印代码,如果分觉得不够,还可再加!在线等!!!急!!!!!! 世界网络的下载速度测试方法? C#问题 c#解析php发过来的json字符串的问题 如何调用excel进行打印呢? excel导入到SQL问题 整个网站只有一个connection对象时,该连接却对象只能使用一次!!!为什么啊??????郁闷.......急!急!急!急!
p.StartInfo.FileName="cmd.exe";
p.StartInfo.UseShellExecute=false;
p.StartInfo.RedirectStandardError=true;
p.StartInfo.RedirectStandardInput=true;
p.StartInfo.RedirectStandardOutput=true;
p.StartInfo.CreateNoWindow=true; //不显示命令行窗口
p.Start();
p.StandardInput.WriteLine("ping 127.0.0.1"); //输入要运行的命令
p.StandardInput.WriteLine("exit");
string strRst=p.StandardOutput.ReadToEnd(); //取得输出结果
查找API在.NET中可用的形式, 可以到www.pinvoke.net.