Kaseya currently has a time limit of 2 hours on scripts because scripts run synchronously on each machine, and a running script will block the execution of subsequent scripts until it finishes. If a script takes longer than 2 hours, Kaseya will force the script to time out.
How do I design a script that initiates an action that could take longer than two hours so that it won't block other scripts from running?
You should end up writing two scripts:
Script A initiates the action (such as defrag.exe)that takes a long timeusing the Execute File command, and either Execute as system and continue immediately, or Execute as user and continue immediately. It then executes script B in 15 minutes time.
Script B checks whether the application (defrag.exe in the example) is still running. If it is, the Then step is used to Execute Script B again in 15 minutes time. If it is not running, then the Else step should be used to complete whatever actions are required after the application has finished.
Kaseya K2, G1, IT Center