Page 1 of 1

Capture stdout while waiting for command to finish

Posted: Thu Apr 28, 2011 4:05 am
by tuanto@eview-tech.com
Hello VBscript expert,I am running a Dos command in my vbscript and try to capture all output when the command completes and write to a file. Some times I can capture 1 or 2 lines and miss the rest. Here is a section of my code...Set oFile1 = oFso1.OpenTextFile(LogFile, ForWriting)CommandLine = oArgs(0) & "binEV400hostcmd 86 28." & SNodeSet objWShell = CreateObject("WScript.Shell")Set objWExec = objWShell.Exec(CommandLine)'Capture the output of the command line Do Until objWExec.StdOut.AtEndOfStream strLine = objWExec.StdOut.ReadLine oFile1.WriteLine(strLine) 'WScript.Echo strLine Loop....Can you help?Thanks,Tto

Capture stdout while waiting for command to finish

Posted: Thu Apr 28, 2011 4:05 am
by tuanto@eview-tech.com
Hello VBscript expert,I am running a Dos command in my vbscript and try to capture all output when the command completes and write to a file. Some times I can capture 1 or 2 lines and miss the rest. Here is a section of my code...Set oFile1 = oFso1.OpenTextFile(LogFile, ForWriting)CommandLine = oArgs(0) & "binEV400hostcmd 86 28." & SNodeSet objWShell = CreateObject("WScript.Shell")Set objWExec = objWShell.Exec(CommandLine)'Capture the output of the command line Do Until objWExec.StdOut.AtEndOfStream strLine = objWExec.StdOut.ReadLine oFile1.WriteLine(strLine) 'WScript.Echo strLine Loop....Can you help?Thanks,Tto

Capture stdout while waiting for command to finish

Posted: Thu Apr 28, 2011 4:12 am
by jvierra
Please do not post VBSxeipt questions to the command line forum. It is likely that no one will see you request.

You need to wait until the command completes before you try to red the results.

Do While objWExec .Status <> 1 WScript.Sleep 100Loop

See: http://msdn.microsoft.com/en-us/library ... S.85).aspx
jvierra2011-04-28 11:19:52