Sign in to follow this  
Followers 0
Rogge_RZN_FHDW

Script timeout

4 posts in this topic

Hello,

My collegue and I have some scripts that are run frequently (possibly during all times, for example at night). Is there a possibility to terminate a script when are certain time elapsed. I thought about some kind of wrapper for the script, but maybe there is a way of doing it inside the script.

Thanks for your help,

Benni and Nico

Share this post


Link to post
Share on other sites



Hello,

My collegue and I have some scripts that are run frequently (possibly during all times, for example at night). Is there a possibility to terminate a script when are certain time elapsed. I thought about some kind of wrapper for the script, but maybe there is a way of doing it inside the script.

Thanks for your help,

Benni and Nico

Put

$a=timerinit()

at the start of your code.

Then, in your loop, but something like

if timerdiff($a)>1000 then exitloop

timerdiff($a) equals the amount of milliseconds since $a=timerinit() was run.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Put

$a=timerinit()

at the start of your code.

Then, in your loop, but something like

if timerdiff($a)>1000 then exitloop

timerdiff($a) equals the amount of milliseconds since $a=timerinit() was run.

We thougt about this. However, It might be possible that our script is waiting for a window that does not exist. There is not always a loop in our script. Right now, we have some kind of wrapper:

run("script.exe")
sleep($delay)
$PID = ProcessExists("script.exe") 
If $PID Then
    ProcessClose($PID)
EndIf
Edited by Rogge_RZN_FHDW

Share this post


Link to post
Share on other sites

You could try using winwait to check for the window and you can set a timeout on it so it won't hang.

OR you could make the if timerdiff statement into an adlib, and have it exit the script instead of exitloop.

WinWait("Untitled", "", 5)
Makes the winwait timeout after 5 seconds

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0