Exec Method

 

Description

 

Runs an application in a child command-shell, providing access to the StdIn/StdOut/StdErr streams.

 

PowerBASIC Syntax

 

METHOD Exec( _

BYVAL bstrCommand AS STRING _

) AS IDispatch

 

Arguments

 

bstrCommand

BSTR. String value indicating the command line used to run the script. The command line should appear exactly as it would if you typed it at the command prompt.

 

Remarks

 

The Exec method returns a IWshExec interface reference, which provides status and error information about a script run with Exec along with access to the StdIn, StdOut, and StdErr channels. The Exec method allows the execution of command line applications only. The Exec method cannot be used to run remote scripts. Do not confuse the Exec method with the Execute method (of the IWshRemote interface).

 

Example [PowerBASIC]

 

#INCLUDE "WSHOM.INC"

 

DIM pWsh3 AS IWshShell3

DIM pWshExec AS IWshExec

 

pWsh3 = NEWCOM "WScript.Shell"

pWshExec = pWsh3.Exec(UCODE$("calc"))

DO

   IF pWshExec.Status <> 0 THEN EXIT DO

   SLEEP 100

LOOP

PRINT "Status: " pWshExec.Status

 

Valid XHTML 1.0 Transitional