Purpose

.Execute() provides the ability to execute a file on the Microsoft Windows Client.  

Object Type

Client

Syntax

Variable = Client.Execute(filename{,parameters{,directory{,ShowCmd{,SynchFlag}}}})
 

Operation

Variable is a numeric scratch variable for the return code value
Filename
is the name of the file on the Client that will be executed. Logical file names can be used for client-side file names. If the file has an extension other than .exe, the Windows Client automatically finds the program to execute the file, by searching the Windows Registry for file associations.
Parameters
is an optional string variable. If the filename variable specifies an executable file (with an extension of .exe), the string specifies the command line parameters that can be passed to the executable.
Directory
is an optional string variable which specifies the default directory's name, (the directory in which the executable runs). This can be useful for applications that look relative to their default directory for file, rather than in explicit paths held in the registry or an .ini file. The string variable can be a logical name.  
ShowCmd
is an optional string variable. If an executable file is specified in filename variable, ShowCmd determines how the Windows function displays the application after it is loaded, e.g. minimised, hidden, with focus, etc. The default setting is SW_SHOWNORMAL. Click here for further details of ShowCmd values.
 
SynchFlag -
either  SYNCH or ASYNCH. If it is left blank or not supplied it is assumed to be ASYNCH.

ASYNC - the execution of executable defined in filename variable will be asynchronous to the execution of the PROIV Logic.

SYNCH  - the execution of the executable defined in filename variable will be synchronous to the execution of the PROIV Logic.
 

Remarks

CLIENT.EXECUTE can be asynchronous or synchronous depending on the setting of the SynchFlag variable. The default execution is asynchronous.

Execution usually opens a window on the Windows Client machine.  The kernel waits until it receives the return code before proceeding further. The return code indicates success or failure. Click here to see a table of the Execute() return codes.

If the return code is greater than 32, execution was successful. Note that PROIV indicates success by a return value of zero, instead of a value greater than 32.

An error number and message may also be returned.  The error number is stored in @ERR and the message can be found in @ERRTXT.  Errors can occur on either the kernel or the client.  If the error occurs on the Client machine, the error messages are the standard error message numbers. If the error occurs on the kernel, the error messages are kernel error messages.
 

Example

To open the file "specification.doc" using the application (probably Microsoft Word) associated in the Windows Registry with the .doc file extension. No other parameters are needed or specified:

#RC = CLIENT.Execute("specification.doc")

To do the same action, but start the application minimised on the Windows Taskbar.

#RC = CLIENT.Execute(“winword.exe", "", "", "SW_MINIMIZE")
 

Comment on this topic

Topic ID: 510019