Jump to content

Update Check


DaLiMan
 Share

Recommended Posts

Hi There,

Once in a while there a some changes to be made in a script which then is updated on our server. Right now I let my script check this file before it runs completely. This works fine, but it's more in the interest of StartUp speed (it takes quite a while) for the script not to check it every time but more like once a week.

Does any of you have a good idea of creating an update checker like this?

Thanx.

Link to comment
Share on other sites

Maybe you write the current date/time to the registry or a file.

Then I would it save in the format YearMonthDayHourMinutesSecond like ie:

20041213133507 (13.12.2004 - 13:35:07)

So you can read it at every startup and build a difference and when it is bigger than a week you will do your update things.

Or you write a file down and check the file date and also do a difference and when your update process is finished you write this file again.

Do you understand what I mean?

Regards Holger :idiot:

Edited by Holger
Link to comment
Share on other sites

Maybe something like this (untested)?

$LastRun=RegRead('HKCU\SOftware\Some\Key', 'xyz', 'REG_SZ')
$CurrentRun=Int(@YDAY/7)
If $LastRun <> $CurrentRun Then
    RegWrite('HKCU\Software\Some\Key', 'xyz', 'REG_SZ', $CurrentRun
  ; Check for update
EndIf

The trick is that $CurrentRun only changes once a week (=7 days). By setting $CurrentRun=Int(@YDAY/14) you can let it run every two weeks and so on.

Two drawbacks: If the script isn't run for exactly one year there won't be any update check and on every beginning of the year the script will check for an update.

Edited by sugi
Link to comment
Share on other sites

Maybe something like this (untested)?

$LastRun=RegRead('HKCU\SOftware\Some\Key', 'xyz', 'REG_SZ')
$CurrentRun=Int(@YDAY/7)
If $LastRun <> $CurrentRun Then
    RegWrite('HKCU\Software\Some\Key', 'xyz', 'REG_SZ', $CurrentRun
  ; Check for update
EndIf

The trick is that $CurrentRun only changes once a week (=7 days). By setting $CurrentRun=Int(@YDAY/14) you can let it run every two weeks and so on.

Two drawbacks: If the script isn't run for exactly one year there won't be any update check and on every beginning of the year the script will check for an update.

<{POST_SNAPBACK}>

Yessss, this is really helpfull !!!! :D

Exactly what I was looking for, but couldn't figure out myself. :idiot:

And the problem of NOT running the script for a whole year is extremely neglectable, because if it is not run for that long it is most likely to be obsolete rather than not being used for a while. :lol:

Thanx a lot !

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...