现在我们调用一个命令提示符,然后想获得它返回的文字该如何做呢。可以看下面的事例:
Process p = new Process();
p.StartInfo.CreateNoWindow = true;//不显示调用窗体界面
p.StartInfo.FileName = "InstallUtil.exe";//调用的程序
p.StartInfo.Arguments = "FileLogService.exe";//调用程序接受的参数
p.StartInfo.UseShellExecute = false;//这两个设置可以将输出内容返回
p.StartInfo.RedirectStandardOutput = true;//这两个设置可以将输出内容返回
bool b=p.Start();
StreamReader sr = p.StandardOutput;//将输出内容返回
string retInfo = sr.ReadToEnd();//获得字符串
原文:http://www.cnblogs.com/wishFreedom/p/3530223.html