首页 新闻 搜索 专区 学院

remote process can't return all output,who can help me

0
悬赏园豆:140 [待解决问题]

need tool PsExec to run below code,no need install,put PsExec.exe under folder bin。

download link:http://technet.microsoft.com/en-us/sysinternals/bb897553      

 

   Process remoteProcess = null;

            fileName ="PsExec.exe";             commandLine = @"\\172.25.188.xx cmd /c netstat -an";//remote ip which you must have administrator permission             try             {                 remoteProcess = new Process();                 remoteProcess.StartInfo.UseShellExecute = false;                 remoteProcess.StartInfo.RedirectStandardOutput = true;                 remoteProcess.StartInfo.RedirectStandardInput = true;                 remoteProcess.StartInfo.RedirectStandardError = true;                 if (!string.IsNullOrWhiteSpace(fileName))                 {                     remoteProcess.StartInfo.FileName = fileName;                 }                 remoteProcess.StartInfo.WindowStyle = ProcessWindowStyle.Minimized;                 remoteProcess.StartInfo.Arguments = commandLine;                 remoteProcess.Start();

                StreamReader myStreamReader = remoteProcess.StandardOutput;                 result = myStreamReader.ReadToEnd();//no dead lock ,but only part of output                 //result = remoteProcess.StandardOutput.ReadToEnd(); //dead lock happens here                 remoteProcess.WaitForExit();               }

Above is part of my code, I can't get the whole output,please see the comment inline.

Thanks.

北漂猫猫1的主页 北漂猫猫1 | 初学一级 | 园豆:60
提问于:2011-10-26 16:24
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册