There is no system () command in the Windows scripting host, so you need to implement your own, IMHO, my helper function is superior to the stealthyninja version, since it waits for the process to exit, not only the empty stdout, but also processes stderr:
Function ExecuteWithTerminalOutput(cmd) Set sh = WScript.CreateObject("WScript.Shell") Set exec = sh.Exec(cmd) Do While exec.Status = 0 WScript.Sleep 100 WScript.StdOut.Write(exec.StdOut.ReadAll()) WScript.StdErr.Write(exec.StdErr.ReadAll()) Loop ExecuteWithTerminalOutput = exec.Status End Function call ExecuteWithTerminalOutput("cmd.exe /c dir %windir%\*")
source share