Winamp & Shoutcast Forums

Winamp & Shoutcast Forums (http://forums.winamp.com/index.php)
-   NSIS Discussion (http://forums.winamp.com/forumdisplay.php?f=65)
-   -   Updater thingy (http://forums.winamp.com/showthread.php?t=282480)

glepaxor 1st December 2007 21:04

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 21:46

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 22:25

Quote:

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 06:51

why dont you NSISdl to download the update after checking if a new version is available

glepaxor 2nd December 2007 07:21

Quote:

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 08:42

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 08:44

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 10:10

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 10:20

Delete the following line:


StrCpy $R2 $R2 -2

glepaxor 2nd December 2007 11:21

Still doesnt work.

fabian.rap.more 2nd December 2007 11:26

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 11:29

this code works 4 me though

glepaxor 2nd December 2007 11:47

Now it started working! Thank you very very much!!

fabian.rap.more 2nd December 2007 12:00

:up: happy 2 help

Afrow UK 2nd December 2007 13:22

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 14:22

could u explain how????

Afrow UK 2nd December 2007 15:13

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 16:09

yeah..........good point. thanks alot man


All times are GMT. The time now is 04:19.

Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.