Archive: Check version from ini and download if newer


Check version from ini and download if newer
I saw this in an earlier post but I'm not sure how it was resolved.
I want to have my installer to rename new.ini to old.ini, download a different new.ini from my website, compare the version numbers in old.ini and new.ini. If new.ini has a higher version number than old.ini download an exe file and run it.
This is my current code:

System::Call 'kernel32::MoveFile(t "new.ini", t "old.ini")i r0'

NSISdlSmooth::download "http://www.domain.net/new.ini" "new.ini"

ReadINIStr $0 "old.ini" "File Version" "Version"
ReadINIStr $1 "new.ini" "File Version" "Version"
IntCmp $0 $1 jump_if_equal jump_if_$0_less jump_if_$0_more
jump_if_equal:
DetailPrint "No Updates Available"
goto done
jump_if_$0_less:
DetailPrint "No Updates Available"
goto done
jump_if_$0_more:
DetailPrint "Update Downloaded"

NSISdlSmooth::download "http://www.domain.com/file.exe" "file.exe"
MessageBox MB_OK|MB_ICONINFORMATION "Downloaded update!"
done:
MessageBox MB_OK "old=$0 new=$1"


This is my new.ini file (on the server):
[File_Version]
Version=2.1

This is the old.ini file
[File_Version]
Version=2.0


The message that pops up for
MessageBox MB_OK "old=$0 new=$1"
is always empty so I think I need to fix my context.

Also, how do I call that exe file when the download completes?

you obviously can't use IntCmp on something that's not an integer. have a look at this macro:

http://nsis.sourceforge.net/VersionCompare


try this after including the macros into your script:

${VersionCompare} "$0" "$1" $0
${If} $0 == 0 ;Versions are equal
${OrIf} $0 == 1 ;$0 is less
DetailPrint "No Updates Available"
${ElseIf} $0 == 2 ;$0 is more
DetailPrint "Update Downloaded"
NSISdlSmooth::download "http://www.domain.com/file.exe" "file.exe"
MessageBox MB_OK|MB_ICONINFORMATION "Downloaded update!"
${EndIf}


hope i didn't mix up less/more here, but you'll figure it out :)