title: PsExec & Process Through C# Not Showing Output
body: <p>Apparently PsExec is working. This code works. When executed, it never returns errors. But only SOMETIMES does it return output, and when it does return output, it is always~ the first line.
  And the first line of ipconfig is "Windows IP Configuration" and the error box shows "ipconfig returned with the error code 0".
  If you replace REMOTEPC with a local IP, it will run and you can see the cmd briefly flash with the information. So it works.</p>
  
  <p>I should add that I believe the reason is that after executing the PsExec, it doesn't "exit". So WaitForExit never happens. When you click X out of the cmd window, the boxes show up. Sometimes with the output mentioned, or blank.</p>
  
  <p>But it never outputs the entire thing for some blasted reason! Its never reading to the end.</p>
  
  <pre><code> private void button1_Click(object sender, EventArgs e)
      {
          Process p = new Process();
          p.StartInfo.FileName = @"C:\PsExec.exe";
          p.StartInfo.Arguments = @"\\REMOTEPC -u USER -p PASS -s ipconfig /all";
          p.StartInfo.UseShellExecute = false;
          p.StartInfo.RedirectStandardOutput = true;
          p.StartInfo.RedirectStandardError = true;
          //p.StartInfo.RedirectStandardInput = true;
  
          p.Start();
  
  
          string output = p.StandardOutput.ReadToEnd();
  
         //Tried this method of getting the output too
         // while (!p.HasExited)
          //{
           //   output += p.StandardOutput.ReadToEnd();
         // }
  
          string error = p.StandardError.ReadToEnd();
  
          p.WaitForExit();
  
          MessageBox.Show(output);
          MessageBox.Show(error);
  
  
      }
  </code></pre>