Description
The #ScriptAfterTimeout$
system variable specifies the script that will be run when #ExecTimeout
has elapsed.
Usage
If you need to run a script at regular intervals regardless of any errors reported, #ScriptAfterTimeout$
used in conjunction with #ExecTimeout
allows you to rerun within a clean desktop environment whatever happened during the previous execution.
Syntax
#ScriptAfterTimeout$=<script_name>
Parameters
<script_name>
, string, constant, name of the script to run after timeout. The .ROB file for the specified <script_name>
must exist (the .ROB is the compiled script).
Remarks
If within the script, #ExecTimeout
has been set up and if this timeout elapses during execution, the .ROB compiled script specified in #ScriptAfterTimeout$
is launched. The use of this system variable along with #ExecTimeout
allows you to recreate a “clean” environment if the script fails for any reason so you can rerun the same script exactly in the same state as if it were the first time; see the example below.
If the script name to call contains spaces, you need to surround the script name with CHR$(34)
:
#ScriptAfterTimeout$=chr$(34)+"After Timeout.rob"+chr$(34)
See also
- #ExecTimeout
Examples
#ScriptAfterTimeout$ = "my_script" 'my_script.rob must exist, if not, an error is reported.
'If a blank is within the full path, surround the string with Chr$(34) as below :
#ScriptAfterTimeout$=Chr$(34)+"c:\wttest\script timeout\display message.rob"+Chr$(34)
'With parameters, the line would be :
#ScriptAfterTimeout$=Chr$(34)+"c:\wttest\script timeout\display message.rob"+Chr$(34)+" param1 param2"
/*This script launches Notepad and the demo page www.wintask.com/demos.
After #ExecTimeout seconds (here at 10), the script is killed and the script killprocesses is launched.
This last script kills the two processes Notepad and Iexplore, so the environment before launching the first script is restored.
*/
''Maximum execution time set at 10
#ExecTimeout=10
'If the timeout is reached, run the killprocesses script
#ScriptAfterTimeout$="killprocesses"
'Some actions, launch notepad, launch a website
Shell("notepad")
StartBrowser("IE", "www.wintask.com/demos")
UsePage("WinTask Demonstration Pages")
ClickHTMLElement("A[INNERTEXT= 'DOWNLOAD your 30-day']")
'A long pause and so the script takes more than 10 secs to execute
pause 20
' Script killprocesses-------------------------------------------------
'This other script kills the applications opened by the main one
KillApp("notepad.exe",1)
killApp("iexplore.exe",1)