Watch.ExecuteExternalProgram
Calls and executes an external program through a specified command line. The program's execution will be directed by the appropriate flags specified as this method's parameters.
It returns the exit code of the program it executed (i.e. the %ERRORLEVEL% OS value).
In general, an exit code of 0 means success, while other exit codes may have various meanings, depending on the program called.
Syntax
Watch.ExecuteExternalProgram(CommandLine: WideString; WorkingDir: WideString; ShowFlags: Integer; WaitForTerminate: WordBool) ReturnValue: integer
CommandLine
The command line to execute as a widestring.
WorkingDir
The working directory for the execution of the command line as a widestring.
ShowFlags
Integer value representing the flag to use during the execution of the command line. These flags have an effect on the execution window opened by the ExecuteExternalProgram procedure.
Flag | Effect |
---|---|
0 | Hide the execution window. |
1 | Display the window normally. |
2 | Display the window minimized. |
3 | Display the window maximized. |
4 | Makes the window visible and brings it to the top, but does not make it the active window. |
WaitForTerminate
A Boolean value that, if true, pauses the script until the command line has been fully executed.
ReturnValue
An integer value that contains the exit code of the program the function executed.
Examples
JavaScript
Watch.ExecuteExternalProgram("lpr -S 192.168.100.001 -P auto c:\\myfile.ps","c:\\",0,true); var returnValue; returnValue = Watch.ExecuteExternalProgram("cmd /c dir *.pdf",".",0,true); // returnValue contains 0 (successful, even when no PDFs are found) returnValue = Watch.ExecuteExternalProgram("cmd /c blablabla",".",0,true); // returnValue contains 1 (error … unless you actually have an app called blablabla!)
VBScript
Watch.ExecuteExternalProgram("lpr -S 192.168.100.001 -P auto c:\myfile.ps", "c:\", 0, true) Dim returnValue returnValue = Watch.ExecuteExternalProgram("cmd /c dir *.pdf",".",0,true) ; returnValue contains 0 (successful, even when no PDFs are found) var returnValue = Watch.ExecuteExternalProgram("cmd /c blablabla",".",0,true) ; returnValue contains 1 (error … unless you actually have an app called blablabla!)
Python
Watch.ExecuteExternalProgram("lpr -S 192.168.100.001 -P auto c:\\myfile.ps", "c:\\", 0, true) returnValue = Watch.ExecuteExternalProgram("cmd /c dir *.pdf",".",0,true) # returnValue contains 0 (successful, even when no PDFs are found) returnValue = Watch.ExecuteExternalProgram("cmd /c blablabla",".",0,true) # returnValue contains 1 (error … unless you actually have an app called blablabla!)
Perl
$Watch->ExecuteExternalProgram("lpr -S 192.168.100.001 -P auto c:\\myfile.ps", "c:\\", 0, true); $returnValue = $Watch->ExecuteExternalProgram("cmd /c dir *.pdf",".",0,true); # returnValue contains 0 (successful, even when no PDFs are found) $returnValue = $Watch->ExecuteExternalProgram("cmd /c blablabla",".",0,true) # returnValue contains 1 (error … unless you actually have an app called blablabla!);