- NSIS Discussion
- Updater thingy
Archive: Updater thingy
glepaxor
1st December 2007 22:04 UTC
Updater thingy
Hi.
Ive been browsing this forum a while but havent found an answer clear enough. The question is, how to turn NSIS to updater application thing.
Im using the InetLoad plugin to get the file from web, but I would like to know is there a plugin or something to get data from a file on web.
Example, in my a server, theres a txt file, that contains a string "Version=3" and NSIS would check it out and recognise it to be version 3, then compare it to a local txt file that says "Version=2", and starts to download the new file from the web with InetLoad.
Any advice appreciated :)
Yathosho
1st December 2007 22:46 UTC
why don't you use the same method (InetLoad) to get the text file? you can use ReadIniStr or ConfigRead afterwards.
glepaxor
1st December 2007 23:25 UTC
Originally posted by Yathosho
why don't you use the same method (InetLoad) to get the text file? you can use ReadIniStr or ConfigRead afterwards.
Can you please tell more specifically what do I do with those? You could give a sample code, maybe? I am new to NSIS :)
fabian.rap.more
2nd December 2007 07:51 UTC
why dont you NSISdl to download the update after checking if a new version is available
glepaxor
2nd December 2007 08:21 UTC
Originally posted by fabian.rap.more
why dont you NSISdl to download the update after checking if a new version is available
I could, but I dont know how to make NSIS check for a new version...
fabian.rap.more
2nd December 2007 09:42 UTC
Section update
NSISdl::download_quiet "http://www.mysite.com/update.txt" "$EXEDIR\update.txt"
pop $0
FileOpen $1 "$EXEDIR\update.txt" r
FileOpen $R1 "$EXEDIR\current.txt" r
FileRead $1 $2
FileRead $R1 $R2
StrCpy $2 $2 -2
StrCpy $R2 $R2 -2
StrCmp $2 $R2 old new
new:
MessageBox MB_ICONQUESTION|MB_YESNO "A new update is available. Would you like to download it now?" IDYES download
goto done
old:
MessageBox MB_ICONINFORMATION|MB_OK "Your software is up to date"
goto done
download:
FileRead $1 $2
StrLen $7 $2
StrCpy $2 $2 $7 9
InetLoad::load /POPUP "Software Update" "$2" "$TEMP\update.exe"
;PLACE THE REST OF YOUR CODE HERE LIKE WHAT TO DO AFTER DOWNLOADING THE UPDATE
goto done
done:
FileClose $1
FileClose $R1
SectionEnd
fabian.rap.more
2nd December 2007 09:44 UTC
the file update.txt would have to look like this:
Version=3
Location=http://mysite.com/update.exe
the file current.txt would have to look like this:
Version=2
glepaxor
2nd December 2007 11:10 UTC
Seems great, but it always says theres a new version available, even if update.txt says 4 and current.txt says 4...
The update downloading does work. Any ideas?? Thanks, though.
fabian.rap.more
2nd December 2007 11:20 UTC
Delete the following line:
StrCpy $R2 $R2 -2
glepaxor
2nd December 2007 12:21 UTC
Still doesnt work.
fabian.rap.more
2nd December 2007 12:26 UTC
Section update
NSISdl::download_quiet "http://www.mysite.com/update.txt" "$EXEDIR\update.txt"
pop $0
FileOpen $1 "$EXEDIR\update.txt" r
FileOpen $R1 "$EXEDIR\current.txt" r
FileRead $1 $2
FileRead $R1 $R2
StrCpy $2 $2 -2
StrCmp $2 $R2 old new
new:
MessageBox MB_ICONQUESTION|MB_YESNO "A new update is available. Would you like to download it now?" IDYES download
goto done
old:
MessageBox MB_ICONINFORMATION|MB_OK "Your software is up to date"
goto done
download:
FileRead $1 $2
StrLen $7 $2
StrCpy $2 $2 $7 9
InetLoad::load /POPUP "Software Update" "$2" "$TEMP\update.exe"
;PLACE THE REST OF YOUR CODE HERE LIKE WHAT TO DO AFTER DOWNLOADING THE UPDATE
goto done
done:
FileClose $1
FileClose $R1
SectionEnd
fabian.rap.more
2nd December 2007 12:29 UTC
this code works 4 me though
glepaxor
2nd December 2007 12:47 UTC
Now it started working! Thank you very very much!!
fabian.rap.more
2nd December 2007 13:00 UTC
:up: happy 2 help
Afrow UK
2nd December 2007 14:22 UTC
It may be a good idea to use ReadINIStr as opposed to FileRead so that you can have variable length values.
Stu
fabian.rap.more
2nd December 2007 15:22 UTC
could u explain how????
Afrow UK
2nd December 2007 16:13 UTC
Have you looked at ReadINIStr in the manual?
Also there is no point using NSISdl and InetLoad when you can do both downloads with InetLoad if you use /silent "" as one of the parameters (rather than NSISdl::download_quiet).
Stu
fabian.rap.more
2nd December 2007 17:09 UTC
yeah..........good point. thanks alot man