title: VBscript code to capture stdout, without showing console window
body: <p>This is a VBScript code example that shows how to catch whatever a command line program sends to standard output.
  It executes the command <code>xcopy /?</code> and shows the output in a message box. Before the message box appears, for a split second you see the console window popping up. </p>
  
  <pre><code>Set objShell = WScript.CreateObject("WScript.Shell")
  Set objExec = objShell.Exec("xcopy /?")
  Do
      line = objExec.StdOut.ReadLine()
      s = s &amp; line &amp; vbcrlf
  Loop While Not objExec.Stdout.atEndOfStream
  WScript.Echo s
  </code></pre>
  
  <p>Here is an other VBScript code example that shows how to execute a script without showing the console window.</p>
  
  <pre><code>objShell.Run "c:\temp\mybatch.bat C:\WINDOWS\system32\cmd.exe", 0
  </code></pre>
  
  <p>or</p>
  
  <pre><code>objShell.Run "c:\temp\myscript.vbs C:\WINDOWS\system32\cscript.exe", 0
  </code></pre>
  
  <p>As you can see it has the form <code>&lt;script&gt;&lt;space&gt;&lt;executor&gt;</code>.
  The last example uses <code>objShell.Run</code> instead of <code>objShell.Exec</code></p>
  
  <p>What I don't know is how to execute a command line program (if necessary from a batch file), catch the standard output, without showing the console window. Any ideas?</p>