However the newest Windows Script Host 5.6 from Microsoft allows you to capture output and re-direct it. I can't remember where I got this but it works well.
fengshui_1998
' Save this to a .vbs file, remember you must have 5.6.
' ------------------------------------------------------
Set oExec = wshShell.exec("cmd /C Dir c:\directoryname"
Function ReadAllFromAny(oExec)
If Not oExec.StdOut.AtEndOfStream Then
ReadAllFromAny = oExec.StdOut.ReadAll
Exit Function
End If
If Not oExec.StdErr.AtEndOfStream Then
ReadAllFromAny = "STDERR: " + oExec.StdErr.ReadAll
Exit Function
End If
ReadAllFromAny = -1
End Function
Dim allInput, tryCount
allInput = ""
tryCount = 0
Do While True
Dim input
input = ReadAllFromAny(oExec)
If -1 = input Then
If tryCount > 10 And oExec.Status = 1 Then
Exit Do
End If
tryCount = tryCount + 1
WScript.Sleep 100
Else
allInput = allInput & input
tryCount = 0
End If
Loop
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.