Archive: Help making a smart installer


Help making a smart installer
Hello everyone, I have recently started working with NSIS and it has impressed me a great deal. Unfortunately the advanced parts of NSIS is a bit confusing for me which has ended up with me trying to accomplish something without much success. What I am trying to do is make an installer that contains 2 sections, section A and section B that work in a special way (I will try to explain without confusing everyone).

Now lets take section A, when the installer starts it checks the registry to see if there is a registry key containing the version number, it the key doesn't exist section A automatically selected for installation, but it can be unselected manually. If the key does exists, the installer checks the version number and compares it to the version being installed, should the version being installed be newer then the one installed then section A is automatically select for installation with the possibility to manually unselect it, but if the version being installed is older then the one installed then section A is unselected and disabled so that it can't be manually selected again.

Section B is exactly the same as section A except for that it is never automatically selected. The only time it is automatically select is if there is a registry key containing the version number and the version being installed is newer then the installed version.

Lastly the uninstaller has to take this into consideration. It should check if section A and section B is installed and offer to manually select which to uninstall while disable the possibility to uninstall a section if it is not currently installed. If only one is uninstalled while the other one remains installed it should not delete itself. It should only delete itself after no more sections remains installed on the system.

As mentioned I have been working on this for a long time, but unfortunately my HDD containing all this work stopped working and I was stupid enough to not make any backups so I need to start at the beginning. That's why I decided to ask here first before starting this time so that I can do it right from the beginning. Although I have read the documentation, looked over the wiki, studied scripts and searched both this forum and online I can't seem to find a way to accomplish my goal. The frustrating part is that I feel I got really close and that some of the information I came over such as here http://nsis.sourceforge.net/Managing...ons_on_Runtime and here http://nsis.sourceforge.net/Two_inst..._one_installer and possible also in this post here http://forums.winamp.com/showthread....hreadid=262092 might contain exactly what I am looking for, but that I am to blind to see it. Any suggestions or help would be greatly appreciated, thanks.


Re: Help making a smart installer

Originally posted by nsed
Section B ... is never automatically selected. The only time it is automatically select is...
So Section B is always never automatically selected except sometimes it is? Yeah, you've confused me.

If you haven't figured this out already, you should be doing SectionSetFlags in .onInit and un.onInit. You can code the sections to be unselected, and in .onInit select the ones you want or prevent the user from selecting a section by leaving it unselected and setting the read only flag (SF_RO).

Of course, I recommend using LogicLib, because the native comparison instructions in NSIS are hard to keep straight and relative jumps are tricky (especially if you have macros in your code). With LogicLib your code will read much more like common programming languages.

Re: Re: Help making a smart installer

Originally posted by demiller9
[B]So Section B is always never automatically selected except sometimes it is? Yeah, you've confused me.
Thanks for the reply and yes maybe I should have written that differently. What I meant was that unlike section A, section B is only automatically selected when there is a registry key containing the version number and the version being installed is newer then the installed version. Else it is never selected automatically, the rest is exactly like section A.

I tried to make something usable by using SectionSetFlags and onInit without much success, but I did not know of LogicLib I will take a look into it and see what I can do with it.

I am still really confused as to how I can create the functions that does what I explained earlier. My biggest problem is figuring out the logic behind and I really hope someone can help me out here with some pointers. Thanks.