Home > Language Reference > System Variables > ExecTimeout


The #ExecTimeout system variable specifies the maximum number of seconds that WinTask x64 will wait before killing the current script execution.


If you need to run a script at regular interval whatever error is reported, use #ExecTimeout in conjunction with #ScriptAfterTimeout$ in order to rerun within a clean desktop whatever happened during previous execution.




When n seconds have elapsed, if script execution is not finished, the script is killed and the execution is stopped. If the system variable #ScriptAfterTimeout$ is filled with a value, the script named in this variable is then launched.

The use of this system variable along with #ScriptAfterTimeout$ allows to recreate a "clean" environment if the script fails for any reason and so you can rerun the same script exactly in the same state than if it was the first time; see below the example code.

#ExecTimeout set to 0 means that there is no timeout.

If #ExecTimeout is set to a value lower than the execution time so far, #ExecTimeout is forced to 0.

See also



#ExecTimeout = 20

/*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
'If the timeout is reached, run the killprocesses script
'Some actions, launch notepad, launch a website
StartBrowser("IE", "
UsePage("WinTask Demonstration Pages")
'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


'This other example shows how to take a screenshot of the desktop after #ExecTimeout.
'If the script does not finish after 30 secs (#ExecTimeout), the execution is stopped
'and the script called AfterTimeout is executed (the file AfterTimeout.rob must exist).
'The window does not exist and so the script fails.

' Script AfterTimeout-------------------------------------------------
'The script called after the main script is killed has just one line:
ret=Hardcopy("C:\program files (x86)\wintask\scripts\error.jpg",1,1)