The following script is an example of how a Vbscript can process each line in the STDOUT generated by a CMD.EXE command or batch.

To run the Example.vbs script, type:

cscript //nologo <Drive:>\Folder\Example.vbs "command or batch"

Examples

cscript //nologo c:\util\Example.vbs "dir /b /ad"

cscript //nologo c:\util\Example.vbs "c:\util\test.bat Jerry"

Example.vbs contains:

                              Dim objArguments                              Set objShell = WScript.CreateObject("WScript.Shell")                              Set objArguments = Wscript.Arguments                              Set objShell = WScript.CreateObject("WScript.Shell")                              Set objExecObject = objShell.Exec("cmd /c " & objArguments(0))                              Do While Not objExecObject.StdOut.AtEndOfStream                                  strText = objExecObject.StdOut.ReadLine()                              ' Test or display strText                                  Wscript.Echo strText                                  Loop