title: How to write a ping to a text file using VBS
body: <p>If I am using VBS to run some CMD commands, in this example ping, how could I write the command to a text file using VBS not DOS?</p>
  
  <pre><code>Set objCmdTest = WScript.CreateObject ("WScript.Shell")
  Set Output = CreateObject("Scripting.FileSystemObject").OpenTextFile("C:\vbs\test.txt",8,true)
  
  Output.WriteLine (objCmdTest.run ("ping failboat"))
  Output.WriteLine (objCmdTest.run ("ping 8.8.8.8"))
  </code></pre>
  
  <p>So this is what I'm working with however what happens is; The script runs, the file is made, 2 command prompts open to run the pings and finally the text inside the file reads:</p>
  
  <pre><code>0
  0
  </code></pre>
  
  <p>When I'd much prefer it to have the ping output.</p>
  
  <p>FYI: Please don't offer suggestions that require me to use DOS for the writing, I'd like to see how VBS can do what I need for multiple reasons, thanks!</p>