Archive: Hide/skip standard MUI pages at runtime


Hide/skip standard MUI pages at runtime
Hi there,

I'm looking for an way to prevent installing new versions into an different directory than an eventually existing one.

BTW NSIS has the same problem. If you run an setup with same version than the one installed, NSIS will allow you to change the installation destination. Which will leave the old installation without uninstalling.

I think hiding the the pages MUI_PAGE_DIRECTORY and MUI_PAGE_STARTMENU would be an reliable solution. But is this possible at all?

I found an script in this forum that should hide an startmenu page. Maybe this aproach could be used to hide/skip other pages as well. Unfortunately I don't understand what this script is doing although I'm a expericed C++ developer. Could someone explain it to me?

Thanks
//David

!define GetSectionSelection "!insertmacro GET_SECTION_SELECTION"
!macro GET_SECTION_SELECTION SECTION
Push $1
SectionGetFlags ${SECTION} $1
IntOp $1 $1 & 1
Exch $1
!macroend
[...]
!define MUI_STARTMENUPAGE_NODISABLE
!define MUI_PAGE_CUSTOMFUNCTION_PRE PreStartmenu
!insertmacro MUI_PAGE_STARTMENU "smid" $SMDIR
[...]
Section "$(lsSec_Startmenu)" siStartmenu
SectionEnd
[...]
Function PreStartmenu
${GetSectionSelection} ${siStartmenu}
Pop $0
StrCmp $0 0 0 +2
Abort
FunctionEnd

Yes , it is possible. You just add function that does the check and then call abort. In the example below it is assumed that $9 was already set depending on if there was a previous install which you could check many different ways.

!define MUI_PAGE_CUSTOMFUNCTION_PRE "SkipIfPreviousInstall"
!insertmacro MUI_PAGE_DIRECTORY
...
Function SkipIfPreviousInstall

IntCmp $9 1 0 +2
Abort

FunctionEnd


Thanks scully, but I actually want to allow installing over an existing installation. With restriction that the install directory must be the same. Therefore I'd like to hide the directory and the startmenu page in this case.


That's what this does. I use it to hide the Directory page myself if the user already has a previous install and they are upgrading.


Oh I didn't realize that. Sorry. I'll try it right away.


Hi scully! Thanks. That's indeed what I was looking for. There's just one problem left: If the skip those two pages the installation will begin already after the license page.

I think I should inform the user about that and change the caption of button or display an custom page.

I could use an abort before the custom page if the "upgrade"-flag is not set (normal condition), right?


You could do that. I use a confirmation dialog at the end that is actually always there. It shows what type of install they are doing and it will note an upgrade if that is the case. The confirmation dialog also shows them where it is going to install to and the start menu folder along with some other stuff. It gets pretty bare when you don't really prompt the user for anything during an upgrade.


You can also change the next button text to "Install" manually. You can do that using GetDlgItem and SendMessage with WM_SETTEXT. If you search the forum for WM_SETTEXT, you should find some examples.


Thanks for your numerous replies. You have been a big help!


this code is bomb, just used it in my upgrade/install script. thanks!