Sign in to follow this  
Followers 0
jawed

exit script after a specified time

7 posts in this topic

Heya :)

Im looking for an error-code or something that runs in the Background and stops the time. it should Exit after... like 5min.

i have a Batch script that runs 12 different autoit.exe's. sometimes These scripts just hang up...

My Problem is that im letting them run during the night and so they shouldnt just do nothing.. better to Exit them and maybe write a file that the script xy got closed/killed.

the code Looks like:

start.bat:

"script1.exe"

.....

"script12.exe"

 

1 of These scripts Looks like:

#include "library.au3"

Programstart()

......

Programend()

ive hoped for something like:

#include "library.au3"

countdownstart()

Programstart()

......

Programend()

func countdownstart()

     "after 5min elapsed"

            Exit

endfunc

 

im using a library that im including in every of These scripts... i hope i havent told it that confusing.. ^^"

Share this post


Link to post
Share on other sites



Use TimerInit at the start of the script. Use AdlibRegister to register a function that checks the timer every n seconds and exits the script if the limit is exceeded.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

I dont get that... i've tried this:

Global $blubbfisch = TimerInit()
  
AdlibRegister(errortimer(),1000 )

While 1
   Sleep(500)
;~    MsgBox(0, "", "Ich bin cool", 1)
WEnd

Func errortimer()
;~    MsgBox(0, "", TimerDiff($blubbfisch)/1000, 1)
   If TimerDiff($blubbfisch)/1000 > 5 Then Exit
EndFunc

it wont Exit... :(

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Hi.

;OPTION 1
AdlibRegister("_Exit", 10000)
 
;do stuff
 
Func _Exit()
    AdlibUnregister("_Exit")
    Exit
EndFunc
 
;OPTION 2
Local $hTimer = TimerInit()
 
;dostuff
 
While 1
    If TimerDiff($hTimer) >= 10000 Then _Exit()
    Sleep(10)
WEnd
 
Func _Exit()
    Exit
EndFunc
Edit: Please use autoit code tags to post your code, thanks.

Br, FireFox.

Edited by FireFox
1 person likes this

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

thanks a lot :D i will use the Option 1. is there any Maximum for the time? because i want to use 5min... ^^"

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Set 10000 (10 seconds) to 1000*60*5 (= 5 Minutes)

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

sure your reply is the best answer... whatever.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

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