Sign in to follow this  
Followers 0
russell

How to make a task run at a certain time

10 posts in this topic

How do i make a script stay ideal till a certain system time? I tried using task schdualer but it needs an admin password and i dont want to set one becuase if the script fails it rebbot the pc back to the desktop automaticly and starts agin


muppet hands are so soft :)

Share this post


Link to post
Share on other sites



How do i make a script stay ideal till a certain system time? I tried using task schdualer but it needs an admin password and i dont want to set one becuase if the script fails it rebbot the pc back to the desktop automaticly and starts agin

well its memory consuming to make a loop check the time but it would work

$StartTime = "13:30"

While 1
    if @HOUR & ":" & @MIN = $StartTime Then
        ;script code here
    Else
        Sleep(25000)
    EndIf
WEnd

Share this post


Link to post
Share on other sites

wow, thanks! if this consumes alot or memory, is there another way?


muppet hands are so soft :)

Share this post


Link to post
Share on other sites

wow, thanks! if this consumes alot or memory, is there another way?

Try it first and look at your task manager if it is the case ! Posted Image


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

wow, thanks! if this consumes alot or memory, is there another way?

Tested it and it uses less than 3.6 mb on my system (xp sp2)

Share this post


Link to post
Share on other sites

Tested it and it uses less than 3.6 mb on my system (xp sp2)

So it's fine ! Posted Image


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

It seems to me that a 25 second sleep is way too much. What if it's 24 seconds before the task should be executed? After a 25 second sleep, the task won't be run by this script until the next day.. I'll post a modified version of the earlier posted code.

$StartTime = "13:30"
While 1
    If @HOUR & ":" & @MIN = $StartTime Then
     ;script code here
    EndIf
    Sleep(100)
    EndIf
WEnd

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

Alternatively, you can use Sleep() to pause your script until the time is right. Less memory consuming, but a bit complicated.

#include<Date.au3>

$currDate = _NowCalc() ; current date and time
;~ $newDate = "2010/09/18 12:05:00" ; new date and time
;~ $newDate = _NowCalcDate()&" 12:04:00" ; today's date + desired time
$newDate = _DateAdd("s", "15", _NowCalc()) ; newDate is set to be 15 seconds from now.

$diff = _DateDiff("s",$currDate,$newDate) ; Calculates the difference in seconds between $currDate and $newDate.

Sleep($diff*1000)

MsgBox(0,"","Activated on - "&_nowCalc())

Hi ;)

Share this post


Link to post
Share on other sites

Alternatively, you can use Sleep() to pause your script until the time is right. Less memory consuming, but a bit complicated.

#include<Date.au3>

$currDate = _NowCalc() ; current date and time
;~ $newDate = "2010/09/18 12:05:00" ; new date and time
;~ $newDate = _NowCalcDate()&" 12:04:00" ; today's date + desired time
$newDate = _DateAdd("s", "15", _NowCalc()) ; newDate is set to be 15 seconds from now.

$diff = _DateDiff("s",$currDate,$newDate) ; Calculates the difference in seconds between $currDate and $newDate.

Sleep($diff*1000)

MsgBox(0,"","Activated on - "&_nowCalc())

Wow talk about above and beyond. Thanks!

muppet hands are so soft :)

Share this post


Link to post
Share on other sites

Wow talk about above and beyond. Thanks!

It is my pleasure. ;)


Hi ;)

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