![]() |
conditional display of MUI_PAGE_DIRECTORY
I'm trying to create an installer (using the Modern UI) that will skip over the MUI_PAGE_DIRECTORY page if the installer detects the software is already installed. The idea is to prevent the same piece of software being installed into two or more different directories. Subsequent reinstallations would overwrite the original without giving the user a chance to alter the installation path.
Here is an outline of the process. 1) The installer is run for the first time. The MUI_PAGE_DIRECTORY appears to let the user (if they wish) to change the default install directory. 2) The software is installed, let's say, to "C:\Program Files\MyApp". 3) The installer writes a string in the registry "InstallLocation" = "C:\Program Files\MyApp". 4) The installer finishes successfully. The software is used and provides much joy to the user. Time passes. The user's toenails grow longer. 5) For whatever reason, the installer is run a second time. 6) The installer looks in the registry for the "InstallLocation" string. If it finds it, the installer uses that as $INSTDIR (by way of InstallDirRegKey) and does not display MUI_PAGE_DIRECTORY. I can't figure out how to write code to skip past the "!insertmacro MUI_PAGE_DIRECTORY" line. Commands like ReadRegStr and StrCmp can only be placed in sections or functions. And the MUI_PAGE_DIRECTORY macro cannot be inserted in a section or a function because the macro contains the PageEx command. Any ideas how I can accomplish this? Thanks! |
code: -Stu :) |
Stu, you're brilliant! I knew it had to be something simple.
One small correction with your code: code: Thanks very much for your help! |
As a continuation of my efforts, I want to change the text of the Next button on the Welcome page.
code: I thought something like this would be achieved in a "show" function, but the compiler kindly informs me MiscButtonText cannot be in a function. Also, MiscButtonText isn't the ideal solution (even if I could get it to work) since it changes all the Next buttons, and I only want to change the Welcome page. Unfortunately, I can't simply !define MUI_WELCOMEPAGE_BUTTON "Install" ... well, technically I can, but MUI.nsh won't do anything with it :) Any thoughts? Thanks! |
Hmm. This would require some modifications to the MUI InstallOptions ini file (ioSpecial.ini).
Something like this should work: code: First the NextButtonText is set, and then we must delete the setting (because otherwise the new NextButtonText will be there on the finish page too because the same ioSpecial.ini is used for both Welcome and Finish pages.) -Stu |
Stu, once again, amazing! From the two snippets of code you have provided me, you've made me really realize how flexible NSIS is!
Again, I had to make one little change to your code by using MUI_PAGE_CUSTOMFUNCTION_PRE instead of MUI_PAGE_CUSTOMFUNCTION_SHOW. Thanks very much! |
The saga continues. Now I want to conditionally change the header and subheader on MUI_PAGE_INSTFILES.
MUI_PAGE_INSTFILES doesn't appear to use ioSpecial.ini. So I tried something tricky like StrCpy ${MUI_PAGE_HEADER_TEXT} "New Header Text" but, as I expected, the compiler would have none of that. :Dcode: On a similar note, is there any way to redefine a definition at runtime? For example: MY_DEFINITION gets defined at compile time. Is it possible to alter MY_DEFINITION during runtime?code: Any ideas? Thanks! |
Defines are compile time only.
You can set the define to use a variable as its value. You can then change that variable according to any condition you choose. |
So what Kichik is saying:
code: -Stu |
kichik and Stu, thanks once more! That did the trick.
|
Wow! Y'all rock! I'm just reading through the posts before I go search for the answer to the question I have, and I came across this thread. I hadn't even *thought* of eliminating the directory choice screen, but it *totally* makes sense! Thanks, Deritrus, for the great idea! (And Stu and KiCHiK for the technical answers.) My life is getting easier....
|
| All times are GMT. The time now is 04:27. |
Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.