Process.StandardOutput.ReadToEnd信息不能全部输出,为什么?

UU1221 2011-10-03 09:49:39
 string dosCommand = "C:\\TEAMCE~1\\Express\\V53\\tc_menu\\tc_TcX_Configuration.bat";
Process p = new Process(); //创建进程对象
p.StartInfo.FileName = "C:\\WINDOWS\\system32\\cmd.exe"; //设定需要执行的命令
p.StartInfo.Arguments = " /C " + dosCommand; //设定参数,其中的“/C”表示执行完命令后马上退出
p.StartInfo.UseShellExecute = false; //不使用系统外壳程序启动
p.StartInfo.RedirectStandardInput = true; //重定向输入
p.StartInfo.RedirectStandardOutput = true; //重定向输出
p.StartInfo.RedirectStandardError = true; //重定向错误
p.StartInfo.CreateNoWindow = true; //不创建窗口

try
{
if (p.Start()) //开始进程
{
p.StandardInput.WriteLine("clearlocks -verbos");
string output = p.StandardOutput.ReadToEnd(); //读取进程的输出
string error = p.StandardError.ReadToEnd();
richTextBox1.Text = output + error;
}
}
catch
{ }
finally
{
if (p != null)
p.Close();
}


程序里,我通过cmd.exe调用引用为dosCommand的批处理,然后再执行"clearlocks -verbose"这个语句,但是为什么最后输出到output的只有批处理的内容,而clearlocks -verbose执行的内容都没有显示,怎么办?
...全文
544 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
UU1221 2011-10-04
  • 打赏
  • 举报
回复
期待大牛出现指导啊...
UU1221 2011-10-03
  • 打赏
  • 举报
回复
呵呵,没人会啊..洗洗睡了...
UU1221 2011-10-03
  • 打赏
  • 举报
回复
“clearlocks -verbose”这个语句是在cmd执行批处理,有了批处理的环境之后执行的

110,525

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧