I do this with objShell.Exec
in some of my scripts. Essentially I have a script named after the function I want to do and I call it from another script.
In the "parent script" I have a function called runExternal
:
Function runExternal(strScript,strComputer)
'strScript is the name of the script/function I'm calling
Set objExec = objShell.Exec("cmd.exe /c cscript.exe """ & strPath & strScript & ".vbs"" " & strComputer)
intDelay = Timer+5
intTimer = Timer
While objExec.Status = 0 And intTimer <= intDelay
intTimer = Timer
Wend
If objExec.Status = 1 Then
strReturn = objExec.StdErr.ReadAll
writeLog strScript & " returned " & strReturn
Else
objExec.Terminate 'terminate script if it times out
writeLog strScript & " timed/errored out and was terminated."
End If
End function
Then in each "child" script, I accept the argument I passed to it by using:
strComputer = WScript.Arguments(0)
then to output I write this way:
WScript.StdErr.Write "whatever the output is"