Merlin73
6th June 2003 17:19 UTC
Help with update program
Hi,
Could someone please help me write a script? I'm new to NSIS and I've created an install script successfully. But I want to use NSIS to write a program that not only downloads an updated version of my program off the internet, but checks to see if it's a newer version first. I've read the documentation and know how to use NSISdl::download, but don't know how to write the rest of the code. (If it was Delphi I could do it)
The idea I have is the updater will read the program's ini file to find the version and compare it with an ini file on the website, if the ini file on the web contains a higher version number it will download the program.
Afrow UK
6th June 2003 18:07 UTC
That can be done and I did it with my program - it did exactly what you want to do!
You can either use GetFileTime to compare the program files like so:
GetFileTime "C:\olderfile.exe" $3 $4
GetFileTime "C:\downloadedfile.exe" $5 $6
IntCmp $3 $5 0 skip +2
IntCmp $4 $6 skip skip 0
Delete "C:\olderfile.exe"
Rename "C:\downloadedfile.exe" "C:\olderfile.exe"
skip:
Or, use:
NSISdl::download "http://myweb.server.com/downloadedfile.ini" "C:\downloadedfile.ini"
ReadINIStr $0 "C:\olderfile.ini" "File Version" "Version"
ReadINIStr $1 "C:\downloadedfile.ini" "File Version" "Version"
IntCmp $0 $1 skip 0 skip
NSISdl::download "http://myweb.server.com/downloadedfile.exe" "C:\olderfile.exe"
MessageBox MB_OK|MB_ICONINFORMATION "Downloaded file update for olderfile.exe!"
skip:
Hope it helps!
-Stu