Well before someone FLAMES you... It is KiXtart NOT KixTart
Here is some code that should get you going in the right direction, based upon suggestions by Les.
NOTE: UNTESTED CODE The SetOptions may interfere with other script settings in a larger script. You can remark out lines to prevent them from running by placing a semi-colon at the point where you want the code to be bypassed. However I would recommend that you write your code to support at least these SetOptions.
Code:
Break On
Dim $SO
$SO=SetOption('Explicit','On')
$SO=SetOption('NoVarsInStrings','On')
Dim $SetCounter,$Key,$KeyValue,$Delay
$Delay=3888000
$SetCounter=FlipcTime(@DATE,@TIME)
$Key=KeyExist('HKCU\Software\MyCompany\Schedule\45')
If $Key
$KeyValue=Val(ReadValue('HKCU\Software\MyCompany\Schedule\45','time'))
If $SetCounter > ($KeyValue+$Delay)
; Shell 'application you want to run every 45 days'
; Reset the counter to current time so you can check properly next time
$KeyValue=WriteValue('HKCU\Software\MyCompany\Schedule\45','time',$SetCounter,REG_SZ)
? 'Time is beyond the ' + $Delay + ' day period, going to run app now'
EndIf
Else
? 'Appears to be first time run, now setting registry value... '
$KeyValue=WriteValue('HKCU\Software\MyCompany\Schedule\45','time',$SetCounter,REG_SZ)
; Shell 'application you want to run every 45 days'
Endif
Function FlipcTime($date,$time,optional $tz)
dim $y,$m,$d
$date = split($date,"/")
if ubound($date) <> 2 exit(1) endif
$y=val($date[0]) $m=val($date[1]) $d=val($date[2])
if $m<3
$m=$m+12
$y=$y-1
endif
$Date=$d+(153*$m-457)/5+365*$y+$y/4-$y/100+$y/400-306
$time = split($time,":")
select
case ubound($time)=1
redim preserve $time[2]
$time[2]=0
case ubound($time)=2
case 1
exit(1)
endselect
$time = (val($time[0])*3600)+(val($time[1])*60)+val($time[2])
$flipctime = IIF($tz,(($date-719163)*86400 + $time)-($tz*3600),($date-719163)*86400 + $time)
endfunction
FYI ::
FUNCTION FlipcTime()
AUTHOR Bryce Lindsay
http://www.kixtart.org/ubbthreads/showflat.php?Cat=&Number=121394
3,600 seconds per hour
86,400 seconds per day
604,800 seconds per week
2,592,000 seconds per 30 day month
3,888,000 seconds per 45 days