Archive: StartMenu shortcuts, find previous installation/folder


StartMenu shortcuts, find previous installation/folder
Hello there!

I know the basics with NSIS and simple setups aren't that problem but now I have to write a little more complex setup so I hope you can help me.

1. I've included the components page and let the user decide there to install shortcuts. I wrote a sectiongroup called ShortCuts and in this group two sections called "Startmenu" and "Desktop".

I want that the page to choose the startmenu folder comes only if the user had checked "Startmenu" before at the components page.

Is it possible? If yes how do I implant it?

2. The application (it's an modification for a game) which is going to be installed with my setup needs an already existing folder (the installed game what the modification is for).

How can I make my setup to search automaticaly the destination folder and if it's not found to let the user search manualy and makes the "next" button only available if it's found?

3. I want that the setup detect any previous installations of the application. If the same setup runs again after installation it should be give the two options of uninstalling the app or repair the app. If the user runs a newer setup (with a newer version of the app) it should detect the previous version (and show it to the user) and should give the option to patch it (maybe radio buttons or a checkbox) or to abort the installation.

How can I manage this?

I know it's just not a short question and maybe there are already answers here in the forum but I don't know which search words fits at best. Tried some but don't find help.


1. You can skip a page by calling Abort in its pre function. Use LogicLib to determine if a section is selected (search for SectionIsSelected).

2. You should find out if the game has its installation folder stored in the registry somewhere which you can read using ReadRegStr $INSTDIR ...

3. The NSIS installation has a dialog which has two radio buttons to 'Uninstall' and 'Add/Reinstall components' if the same version of NSIS is being reinstalled or 'Uninstall' and 'Do not uninstall' if a different version of NSIS is being installed. You can look at the nsDialogs code in Examples\makensis.nsi. That is probably a more extensive example than you need but the basic nsDialogs code should be the same.

To determine if your product is already installed you will have to either store some information in the registry (like under the Uninstall registry) or you simply determine if your install folder already exists (checking the registry would be best). Again you can skip the page by calling Abort.

Stu


Thanks for the answers. Need a few days to handle with question/answer #3. But you first two answers helped a lot.


In addition to #2 if you do find a suitable registry entry, you can just add InstallDirRegKey to your script as opposed to explicitly setting $INSTDIR.

Stu