Question regarding an installer that can also upgrade
I am creating an installer using NSIS 2.0 beta 3, Modern UI.
My requirement is to have the installer check first whether the application is currently running and/or previously installed - this I managed to implement successfully via a DLL that contains some helper functions (in my app there's more to it than just searching for files or Windows that can be scripted).
Next, if the application is running, I ask the user to close it and loop until it really is closed. OK so far. However, if the application is installed but not running, I don't want to proceed as a normal install
(Welcome, EULA, Components, Directory, Install Files, Finish);
Instead, I want to provide a custom page that informs that user that I have detected a previous version x.xx installed at path yyy, and that by clicking Next the application will be *upgraded*.
That's because I don't want to potentially end up with 2 or more installations side-by-side. The new version *must* upgrade the previous one in its current location.
I also want to simplify the upgrade for the user by removing pages that an upgrade doesn't need. The upgrade should simply read the previous installation folder from the Registry and use it and should *not* display the Welcome, EULA, Components and Directory pages. After the custom page, file installation should take place and then the Finish page. That's all.
So the requirement is to have a dual purpose installer that either does a full install or an upgrade that displays fewer pages, based on a check conducted at runtime (currently in Function .onInit).
No matter what I did, I couldn't implement this with NSIS Modern UI. It seems that the pages need to be declared up front, losing flexibility on whether to omit a particular page later on.
There doesn't seem to be functionality to skip a page or to go from one page to another page.
Even when using MUI_CUSTOMPAGECOMMANDS and insertmacro to declare the pages, the compiler complained when I did !insertmacro MUI_PAGECOMMAND_INSTFILES from a function. Without this, I couldn't get the upgrade to be functional. Regarding some other pages like EULA, Components and Directory, even without an !insertmacro they still got displayed! Because I had LicenseData for the install, the compiler insisted that I have !define MUI_LICENSEPAGE and would not allow me to add a license page dynamically (practically forcing me to show a license page even in the upgrade).
To prevent this email from growing too long I'll stop discussing the many dead ends I reached at every step and will leave the stage for the NSIS experts to try to solve this problem. I would appreciate any solid tips regarding the implementation of such an install/upgrade. Thank you.