直接在DOS里面运行一下你的命令,查看结果。看看是命令的问题还是程序的问题

解决方案 »

  1.   

    用数组读吧,加个while,判断一下,一直读,空就跳出
      

  2.   

                    Process process = new Process();//创建进程对象  
                    ProcessStartInfo startInfo = new ProcessStartInfo();
                    startInfo.FileName = "CMD.exe";//设定需要执行的命令  
                    startInfo.Arguments = "/C " + command;//“/C”表示执行完命令后马上退出  
                    startInfo.UseShellExecute = false;//不使用系统外壳程序启动  
                    startInfo.RedirectStandardInput = false;//不重定向输入  
                    startInfo.RedirectStandardOutput = true; //重定向输出  
                    startInfo.CreateNoWindow = true;//不创建窗口  
                    process.StartInfo = startInfo;                process.Start();
                    process.WaitForExit();                string strRst = "";
                    while (!process.StandardOutput.EndOfStream)
                    {
                        strRst += process.StandardOutput.ReadLine();
                    }
      

  3.   

    dos 是正确的,
    我用的是psexec 读的是远程机的结果,用你的
    while (!process.StandardOutput.EndOfStream) //这里只执行一次ReadLine 不会多次
    我的代码如下Process myProcess = new Process();
    myProcess.StartInfo.UseShellExecute = false;
    myProcess.StartInfo.RedirectStandardOutput = true;
    myProcess.StartInfo.FileName = @"C:\S\psexec";
    StringBuilder sb = new StringBuilder();
    sb.Append(@"\\192.168.0.1");
    sb.Append(@" -u username -p password");
    sb.Append(@" cmd /c");
    sb.Append(@" type c:\s\1.txt");
    myProcess.StartInfo.Arguments = sb.ToString();
    myProcess.Start();
    myProcess.WaitForExit();
    string strRst = "";
    while (!myProcess.StandardOutput.EndOfStream)
    {
       strRst += myProcess.StandardOutput.ReadLine();
    }
      

  4.   

    type c:\srs\1.txt && sleep 1
      

  5.   

    发现psexec 的 ReadToEnd();只能获取长度为80的字符,,,超过就没获取到了,,,怎么处理?