Jump to content

Update System doesnt work


 Share

Recommended Posts

Hi all,

I've made the following script:

#include <string.au3>
If Not FileExists("settings.ini") Then
Exit
Else
$serialen = IniRead("settings.ini", "Global", "Licensekey", "NOLICENSE") 
If $serialen = "NOLICENSE" Then
Exit
Else
InetGet("[url="http:///spana%20href="]http://URL.HERE/license.ini[/url]", @TempDir & "\license.ini") 
$serialpw = "430FA194720A1C625BA64CDDDBE96005F13E2ECDA737F1B43CC195158E092D601A06B9873046BF6A507BB22509FB71B
5751409D9BEE273C5E936503ACE749AF77C87D11ED3A83D3ACB6003229CF04A1E61604A9B1165F8B58751C86FEB4A3043"
$serial = _StringEncrypt(0, $serialen, $serialpw, 7)
$expdate = IniRead(@TempDir & "\license.ini", $serial, "expire", "")
$test = StringSplit($expdate, "-")
$expyear = $test[3] - 1
$expmon = $test[2] - 1
If IniRead(@TempDir & "\license.ini", $serial, "Active", "NO") = Not "YES" Or @MDAY>$test[1] -1 And @MON>$expmon And @YEAR>$expyear  Then 
Msgbox(16, "Cijfer Registratie Systeem", "Deze licentie is niet meer actief.") 
ProcessClose("registratiesysteem.exe")
FileDelete(@TempDir & "\license.ini")
Exit
Else 
get()
EndIf
EndIf
EndIf


Func get()
$currentversion = FileGetVersion("program.exe")
;MsgBox(64, "Version", $currentversion)
InetGet("[url="http:///spana%20href="]http://URL.HERE/crs.ini[/url]", @TempDir & "\crs.ini") 
If IniRead(@TempDir & "\crs.ini", "latestversion", "ver", "") = $currentversion Then
FileDelete(@TempDir & "\crs.ini")
FileDelete(@TempDir & "\license.ini") 
Sleep(500)
Exit
Else
ProcessClose("program.exe")
InetGet("[url="http:///spana%20href="]http://URL.HERE/program.exe[/url]", "program.exe") 
FileDelete(@TempDir & "\crs.ini")
FileDelete(@TempDir & "\license.ini")
Sleep(500)
Run("program.exe")
Exit
EndIf
EndFunc

license.ini looks like this:

[4444-4444-4444-4444]

Naam=No Name

expire=20-01-2010

active=YES

The scrip above doesnt seem to work, as it keeps returning the message 'Deze licentie is niet meer actief' which means that the license isnt active anymore, but the expiry date is right (later than the date of today and active is set to yes, so why does it tell me that the license is not active anymore. I cant figure it out. Thanks in advance! Edited by PcExpert
Link to comment
Share on other sites

  • Developers

This test is wrong as it tests the individual values in stead of used the whole date as a value:

@MDAY > $test[1] - 1 And @MON > $expmon And @YEAR > $expyear

Better use the supplied DateDiff() udf or concatenate both dates in the format YYYYMMDD and then compare them.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

Or keep track of the last used date of your program and make sure the next time it is used the date/time is later, expect taking traveling timezones and DayLightSaving into account...

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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