Jump to content

How to make a task run at a certain time


russell
 Share

Recommended Posts

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 :)

Link to comment
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
Link to comment
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.

Link to comment
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 ;)

Link to comment
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 :)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...