Vbscript / Processes And Services / Run Command Capture Output
This script provides a function to run a command using the Shell Execute method and capture/return the output as a string variable.
Wscript.Echo runCMD("ping 127.0.0.1")
Function runCMD(strRunCmd)
Set objShell = WScript.CreateObject("WScript.Shell") Set objExec = objShell.Exec(strRunCmd) strOut = ""
Do While Not objExec.StdOut.AtEndOfStream strOut = strOut & objExec.StdOut.ReadLine() Loop
Set objShell = Nothing Set objExec = Nothing
runCMD = strOut
End Function
Please note that a disclaimer applies to any code on this page.
|