title: How to capture "Root Path" into a variable
body: <p>I am trying to run <code>logman.exe</code> for a elevated <code>CMD</code>, for this below code I tried,</p>
  
  <pre><code> var proc = new Process
          {
              StartInfo = new ProcessStartInfo
              {
                  FileName = @"C:\Windows\System32\cmd.exe",
                  Arguments = "cmd /k logman.exe PerfCounterCustom  | findstr \"Root\"",
                  Verb = "runas",
                  UseShellExecute = true,
              }
          };
  
          try
          {
              proc.Start();
              while (!proc.StandardOutput.EndOfStream)
              {
                  string line = proc.StandardOutput.ReadLine();
              }
              Console.WriteLine("Successfully elevated!");
          }
          catch (Exception ex)
          {
              Console.WriteLine(ex.ToString());
          }
  </code></pre>
  
  <p>And it's giving error output like,</p>
  
  <p><a href="https://i.stack.imgur.com/IUbN8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IUbN8.png" alt="enter image description here"></a></p>
  
  <p><code>System.InvalidOperationException: StandardOut has not been redirected or the process hasn't started yet.
     at System.Diagnostics.Process.get_StandardOutput()</code></p>
  
  <p>2 Questions,</p>
  
  <ol>
  <li>when I am running application <code>exe</code>, it's showing 2 <code>CMD</code> window, the 1st one showing error and 2nd one showing result for argument <code>"cmd /k logman.exe PerfCounterCustom  | findstr \"Root\""</code> [Root Path]</li>
  </ol>
  
  <p>how to disable showing both window?</p>
  
  <ol start="2">
  <li>Why I am getting this error?</li>
  </ol>