WshShell.Exec
Run an external Command.
Syntax
WshShell.Exec (strCommand)
Parameters
strCommand : The Command to be executed
Example.vbs
'---------------------------------------
' Run the calculator (calc.exe) and display the exit codes
Dim WshShell,oExec
Set WshShell = wscript.createobject("wscript.shell")
Set oExec = WshShell.Exec("calc.exe")
WScript.Echo oExec.Status
WScript.Echo oExec.ProcessID
WScript.Echo oExec.ExitCode
'---------------------------------------
notes
.ExitCode
Returns the exit code set by a program (when it finishes running)
WshShell.Exec gives the ability to access the standard streams
of the executable and allows read/writes to the process's
stdout/stderr in real-time while the process executes.
while(!Pipe.StdOut.AtEndOfStream)
WScript.StdOut.WriteLine(Pipe.StdOut.ReadLine())
------------
.Terminate
Instructs the script engine to end the process.
note - this type of process kill does not clean up properly
and may cause memory leaks - use only as a last resort!
First rate people hire other first rate people.
Second rate people hire third rate people.
Third rate people hire fifth rate people. - André Weil
Related commands:
Command, run command - WshShell.Run
Equivalent Windows command:
START - Start a separate window to run a specified
program or command