8.10.3 WaitForExec (wait for completion or forcibly terminate an executable file)
- Purpose
-
Waits for completion of or forcibly terminates an executable file called by the Exec or NetExec command (the Flag argument must be False).
- Syntax
WaitForExec ([Option], [ExecId] [, Time])
- Arguments
-
- Option
-
Specify one of the following optional values:
Value
Meaning
Wait
Wait for completion of a specific executable file called by the Exec or NetExec command.
WaitAll
Wait for completion of all executable files called by the Exec or NetExec command.
Abort
Forcibly terminate a specific executable file called by the Exec or NetExec command.
AbortAll
Forcibly terminate all executable files called by the Exec or NetExec command.
This value is optional. If you omit this value, Wait is assumed.
- ExecId
-
If you specified Wait or Abort in Option, specify the ID of an executable file called by the Exec or NetExec command (the Flag argument must be False). Write the file ID as a character string or as a variable that stores the value.
This value is optional. If you omit this value, the value stored in the _EXEC_ID_ reserved variable is assumed.
- Time (from version 06-00)
-
Specify a wait interval in seconds. Specify a number or zero, or a variable that stores this value.
If you specified Wait or WaitAll in Option, the script waits during the specified interval for the executable file(s) to terminate.
If you specified Abort or AbortAll in Option, the executable file(s) are forcibly terminated when the wait interval has elapsed.
This argument is optional. Omit if not required.
Regardless of the Option specification, the WaitForExec command returns True if the executable file(s) terminated by or at the specified time, or False if the executable file(s) did not terminate. The command also sets the same value as the _ERR_TIMEOUT_ reserved variable in the _RTN_ reserved variable. The execution control does not jump to the label specified in the On Error statement.
- Description
-
The WaitForExec command waits for completion of or forcibly terminates an executable file called by the Exec or NetExec command (the Flag argument must be False). The command returns True on successful execution, or False if an error occurs.
True is always returned if the executable file has already completed when this command is invoked.
- Example
Dim exec1_ID, exec2_ID If Exec (_WIN_+"NOTEPAD.EXE", False, _SCF_+"ABC.SPT") Then exec1_ID = _EXEC_ID_ ... End If Exec (_WIN_+"NOTEPAD.EXE", False, _BIN_+"Memo.TXT") Then exec2_ID = _EXEC_ID_ ... End ' Wait for Notepad to complete. WaitForExec (Wait, exec1_ID) ' Forcibly terminate Notepad after 60 seconds. WaitForExec (Abort, exec2_ID, 60)
- JP1/Script version
-
Supported from JP1/Script 01-01.