![]() |
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 :) |
why don't you use the same method (InetLoad) to get the text file? you can use ReadIniStr or ConfigRead afterwards.
|
Quote:
|
why dont you NSISdl to download the update after checking if a new version is available
|
Quote:
|
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 |
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 |
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. |
Delete the following line:
StrCpy $R2 $R2 -2 |
Still doesnt work.
|
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 |
this code works 4 me though
|
Now it started working! Thank you very very much!!
|
:up: happy 2 help
|
It may be a good idea to use ReadINIStr as opposed to FileRead so that you can have variable length values.
Stu |
could u explain how????
|
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 |
yeah..........good point. thanks alot man
|
| All times are GMT. The time now is 04:19. |
Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.