Archive: How to Selectively Disable Page Directory Screen


How to Selectively Disable Page Directory Screen
  Hi,

I'm using the "!insertmacro MUI_PAGE_DIRECTORY" macro as part of the MUI.nsh GUI package. I would like to find a way to selectively show or not show the Page Directory screen.

I want to show it when I initially run the Installer program and the Application has not been installed at all initially. But then I want to run the Installer again to allow the user to install OTHER aspects of the program, but in that case I do not want to allow the user the ability to change the Install Directory; in this case, I want to not show the Directory Page screen shown by the "!insertmacro MUI_PAGE_DIRECTORY" macro and simply skip this Page Directory screen.

How do I do this? Please provide me with specific.

Thanks.


Take a look at:

http://nsis.sourceforge.net/wiki/Skipping_Pages


Use Abort instruction in pre-function.
For example, when your programm was installed some regestry keys were created.
Code like this:


!include LogicLib.nsh
...
var AbortPage
...
!define MUI_PAGE_CUSTOMFUNCTION_PRE "PageAbort" ; if product installed break this page
!insertmacro MUI_PAGE_DIRECTORY
...
Function PageAbort
${If} AbortPage == "yes"
Abort
${EndIf}
FunctionEnd
...
Function .onInit
...
ReadRegStr $R0 HKLM "Software\My Soft" "Version"
${Unless} ${Errors}
StrCpy $AbortPage "yes"
${Else}
StrCpy $AbortPage "no"
${EndUnless}
...
FunctionEnd

Thanks!


That is a good example! But you don't need the .onInit stuff or the extra "Var AbortPage".
You can do most of the checks/work inside the pre function.


nsh

>...

!
define MUI_PAGE_CUSTOMFUNCTION_PRE "PageSkipDir" ; skip if installed
>!insertmacro MUI_PAGE_DIRECTORY
>!define MUI_PAGE_CUSTOMFUNCTION_PRE "PageSkipStartMenu" ; skip if installed
>!insertmacro MUI_PAGE_STARTMENU Application $StartMenuGroup

>...
Function PageSkipDir
; ClearErrors
ReadRegStr $R0 HKLM "Software\My Soft" "Version"
; If the key exists (no errors), we've installed the software before.
; Use the old install location and skip asking them.
${Unless} ${Errors}
Abort ; skip the next page (Choose install dir)
${Else}
; Do nothing; show the next page.
${EndUnless}
FunctionEnd

; Also works if you're using the StartMenu code (search the forum).
Function PageSkipStartMenu
; ClearErrors
ReadRegStr $StartMenuGroup HKLM"${REGKEY}" StartMenuGroup
${Unless} ${Errors}
; Ifthe key exists (no errors), weve installed the software before.
; Usethe old start menu location and skip asking them.
Abort
${Else}
; Donothing; let them see the "choose start menu" page
${EndUnless}
>FunctionEnd
>