Sign in to follow this  
Followers 0
Iceburg

Timed Scripts

5 posts in this topic

I have a script that I am trying to set up that will run on a computer 24/7. I have set the loop up to pull the current time, and then compare that time to my "schedule" and then run the scripts based on those times. I have two issues that I would like some help on with this script.

1.) It doesn't work for some reason. The time gets pulled, but it never launches the test schedule (just the message box that comes up with a different title)

2.) If the script runs at 1:00:00 when I start it, and it takes 2ms for the code to run, and the time doesn't match anything, then its going to sleep for 60 seconds. The next time its going to run is at 1:01:02, the time for the code has potential to add up and then skip a minute after the code has been running for days/weeks/months. How can I account for the time that it takes the code to run to verify 100% that I will never miss a schedule?

while 1
    $time = @hour & ":" & @MIN                                           ; Pull current time
    ;MsgBox(4096, "time", $time)
    If $time == ("02:00") then
        Run ("c:\windows\pskill.exe\simple.exe")                     ; Run script at 2:00a.m.
    ElseIf $time == ("07:30:00") then
        Run ("C:\Documents and Settings\Owner\Desktop\simple.exe")   ; run script at 7:30a.m.
    Elseif $time == ("15:00") Then
        MsgBox(4096, "HURRAY", $time)                                ; Test time to run test script
    else 
        sleep (60000)                                                ; Sleep for 1 min, and check time again
    EndIf
WEnd

Share this post


Link to post
Share on other sites



What do you think about time issue with the seconds / ms?

I will try that out and check it out.

Share this post


Link to post
Share on other sites

While @SEC <> 0        ;it will wait untill the end of the minit. mess with this to get to the closest second on the minuit as posible
    Sleep(100)
WEnd ; then start

AdlibEnable(time(),30000)

Func Time()
    $time = @hour & @MIN
EndFunc

while 1
    ConsoleWrite($time & @CRLF)
    If $time == (200) then
        Run ("c:\windows\pskill.exe\simple.exe")                     ; Run script at 2:00a.m.
        sleep(90000) ; prevent from running it a thousand times
    ElseIf $time == (730) then
        Run ("C:\Documents and Settings\Owner\Desktop\simple.exe")   ; run script at 7:30a.m.
        sleep(90000) ; prevent from running it a thousand times
    Elseif $time == (2057) Then
        MsgBox(4096, "HURRAY", $time)                                ; Test time to run test script
        sleep(90000) ; prevent from running it a thousand times
    Else
        Sleep(30000)
    EndIf
WEnd

I got it to run on time, the additional sleeps are to make sure it does not run scheduled tasks an any given time. This will guaranteed always get the time at 30 secs.


0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

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