This is a VBScript code example that shows how to catch whatever a command line program sends to standard output.
It executes the command
xcopy /? and shows the output in a message box. Before the message box appears, for a split second you see the console window popping up.
Set objShell = WScript.CreateObject("WScript.Shell") Set objExec = objShell.Exec("xcopy /?") Do line = objExec.StdOut.ReadLine() s = s & line & vbcrlf Loop While Not objExec.Stdout.atEndOfStream WScript.Echo s
Here is an other VBScript code example that shows how to execute a script without showing the console window.
objShell.Run "c:\temp\mybatch.bat C:\WINDOWS\system32\cmd.exe", 0
objShell.Run "c:\temp\myscript.vbs C:\WINDOWS\system32\cscript.exe", 0
As you can see it has the form
The last example uses
objShell.Run instead of
What I don't know is how to execute a command line program (if necessary from a batch file), catch the standard output, without showing the console window. Any ideas?