NSIS Bee
11th February 2006 04:38 UTC
Online Update
Is it possible to make a install using NSIS on a CD but then when an update is available the first screen they see tells them "There is a newer version available, click here to update" and it'll download the update instead of installing the old version on the CD? If so, what do I need and any example code would help. Thanks!
Takhir
11th February 2006 06:31 UTC
You can ask server about updates on install start using InetLoad plug-in (included to NSIS distribution NSISdl works in section only). Then you can read available version number from file and display message box followed by next download.
Short Term
10th March 2006 02:08 UTC
Any example of script please? Or a working generic application that does this, I can't get it to work as Takhir says? Thanks...
Jamyn
10th March 2006 03:07 UTC
Hmmm
Not really, because in general, the design of your update mechanisms depend on the components you are trying to update, the OS you will support, etc.
But a logical outline would be:
a) Check whether the user is online.
a1) if they are not, do you want to prompt to go online, or just skip the update check?
a2) if they are, do you want to prompt them to check for updates, or do you want to just go ahead check for updates?
a3) If you want to go ahead and check for updates:
b) Use InetLoad or NSIS::dl to download an .ini, .xml, or .txt file with current version information from your website.
c) Compare the internal version number from the copy they currently are running against the version number in the file you downloaded from your website. Preferably you will have the filesize for the new version in the .ini/xml as well, for reasons discussed in a sec.
d) Prompt the user to download a new version. Make sure you save the new version to a writeable medium, in case they are running from CD.
e) (1) Compare the actual filesize/MD5 whatever against the filesize/MD5 in the xml file. If they match, the installer you downloaded is probably not corrupt. If they dont, inform the user that their download appears to have failed/been corrupted, and ask them if they want to retry, or just install the old version. Otherwise, if the filesize/MD5 looks good, (2) Hide the window for the old version (on cd), (2) start the new version, (3) exit the old version. Take care not to use the exact same mutex between versions (if you do that sort of thing), or the new copy won't start because your old installer is still running temporarily and has the same mutex.
Done.
Now, writing example script to do all those things is not something that most people would write in two or three minutes, so you are unlikely to get a lot of examples here. But the InetLoad plugin has plenty of examples, the Internet plugins and scripts to detect online status come with some examples, the MD5 plugin has docs, the XML plugin (if you use that) has docs, and if you go with plain .ini files - the NSIS manual (and the NSIS wiki) goes over reading strings from text files.
Besides - in the process of understanding how to piece together an update system, you'll learn a lot of valuable information about NSIS itself.