Archive: How to display a custom page instead of MUI_PAGE_DIRECTORY depending on sections


How to display a custom page instead of MUI_PAGE_DIRECTORY depending on sections
Hello everybody,

I am new with nsis script, and i am meeting a problem :)

My Script has two sections, what i would like to do is during the installation, if all my sections are selected display MUI_PAGE_DIRECTORY
if there is only my second section selected, display MyCustom page.

!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_COMPONENTS

!insertmacro MUI_PAGE_DIRECTORY
or Page custom nsDialogsPage (depend on my section 1)

!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH

This following function is that i have tried:

Function DependenciesOnTomcatInst
${If} ${SectionIsSelected} ${sec1}
!insertmacro MUI_PAGE_DIRECTORY ;Sélection du répertoire d'installation
${IfNot} ${SectionIsSelected} ${sec1}
Page custom nsDialogsPage
${endif}
FunctionEnd

All Ideas will be welcome, thank you by advance, and sorry for my English i am not fluent :)


!define MUI_PAGE_CUSTOMFUNCTION_PRE DirPage_Pre
!insertmacro MUI_PAGE_DIRECTORY
Page Custom nsDialogsPage

Then do the section check in the DirPage_Pre and nsDialogsPage functions. If you call Abort, the page will be skipped.


Thank you very much aerDNA! i will try to do it now!


It works perfectely thanks again aerDNA! :up:


I have a similar question i have two Installation Type Typical &
Portable and when typical installation is selected the default
installation dir will be $PROGRAMFILES\My Program & if portable
installation type is selected then default installation dir will be
$EXEDIR\My Program please help. I am attaching the script Please Help.


; Define your application name
!define APPNAME "My App"
!define APPNAMEANDVERSION "My App 1.1.2"

RequestExecutionLevel none

; Main Install settings
Name "${APPNAMEANDVERSION}"
InstallDir "$PROGRAMFILES\My App"
InstallDirRegKey HKLM "Software\${APPNAME}" ""
OutFile "MyAppSetup1.1.2.exe"

; Modern interface settings
!include "MUI.nsh"

!define MUI_ABORTWARNING
!define MUI_FINISHPAGE_RUN "$INSTDIR\MyApp.exe"
!define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\readme.txt"
!define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED

;Uncomment the following two lines if you wish to recompile the Venis Install Script
!define MUI_HEADERIMAGE


!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "license.txt"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH

!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES

; Set languages (first is default language)
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "Danish"
!insertmacro MUI_LANGUAGE "German"
!insertmacro MUI_LANGUAGE "Italian"
!insertmacro MUI_LANGUAGE "Spanish"
!insertmacro MUI_RESERVEFILE_LANGDLL

InstType /NOCUSTOM

InstType "Typical"
InstType "Portable"

;Function .onInit

; !insertmacro MUI_LANGDLL_DISPLAY

;FunctionEnd

Section "My App" Section1

; Set Section properties
SectionIn 1 RO
SetOverwrite on

; Set Section Files and Shortcuts
SetOutPath "$INSTDIR\languages\"
File /r "..\languages\*.*" ; Packaged languages

SetOutPath "$INSTDIR\"
File "..\MyApp.exe"
File "..\readme.txt"
File "..\license.txt"

CreateDirectory "$SMPROGRAMS\My App"
CreateShortCut "$SMPROGRAMS\My App\My App.lnk" "$INSTDIR\MyApp.exe"
CreateShortCut "$SMPROGRAMS\My App\Uninstall.lnk" "$INSTDIR\uninstall.exe"

SectionEnd

Section "Portable" Section2
; Set Section properties
SectionIn 2 RO
SetOverwrite on

; Set Section Files and Shortcuts
SetOutPath "$INSTDIR\languages\"
File /r "..\languages\*.*" ; Packaged languages

SetOutPath "$INSTDIR\"
File "..\MyApp.exe"
File "..\readme.txt"
File "..\license.txt"
SectionEnd

Section "Desktop Shortcut" Section3
; Set Section properties
SectionIn 1
SetOverwrite on

; Set Section Files and Shortcuts
CreateShortCut "$DESKTOP\My App.lnk" "$INSTDIR\MyApp.exe"

SectionEnd

Section "Quicklaunch Shortcut" Section4

; Set Section properties
SectionIn 1
SetOverwrite on

; Set Section Files and Shortcuts
CreateShortCut "$QUICKLAUNCH\My App.lnk" "$INSTDIR\MyApp.exe"

SectionEnd

Section "Source" Section5

; Set Section properties
SectionIn 1
SetOverwrite on

; Set Section Files and Shortcuts
SetOutPath "$INSTDIR\src\"
File "MyApp.dsp"
File "MyAppAbout.cpp"
File "MyAppAbout.h"
File "license.txt"
File "MyApp.dsw"
File "MyApp.ico"
File "MyApp.nsi"
File "MyApp.rc"
File "MyAppapp.cpp"
File "MyAppapp.h"
File "MyAppfrm.cpp"
File "MyAppfrm.h"
File "MyApplistbox.cpp"
File "MyApplistbox.h"
File "MyAppprefdlg.cpp"
File "MyAppprefdlg.h"
File "MyAppsecuritydlg.cpp"
File "MyAppsecuritydlg.h"
;File "resource.h"
File "readme.txt"
File "todo.txt"
File "wxHyperlinksCtrl.cpp"
File "wxHyperlinksCtrl.h"

SectionEnd


Section "-Add Uninstaller" Section6 ;hidden section

; Set Section properties
SectionIn 1

WriteRegStr HKLM "Software\${APPNAME}" "" "$INSTDIR"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "DisplayName" "${APPNAME}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "UninstallString" "$INSTDIR\uninstall.exe"
WriteUninstaller "$INSTDIR\uninstall.exe"

SectionEnd

; Modern install component descriptions
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${Section1} "My App core application."
!insertmacro MUI_DESCRIPTION_TEXT ${Section2} "My App Portable."
!insertmacro MUI_DESCRIPTION_TEXT ${Section3} "My App desktop shortcut."
!insertmacro MUI_DESCRIPTION_TEXT ${Section4} "My App quicklaunch shortcut."
!insertmacro MUI_DESCRIPTION_TEXT ${Section5} "My App source."
!insertmacro MUI_DESCRIPTION_TEXT ${Section6} "My App uninstaller."
!insertmacro MUI_FUNCTION_DESCRIPTION_END


Function un.onInit

!insertmacro MUI_UNGETLANGUAGE

FunctionEnd

;Uninstall section
Section Uninstall

;Remove from registry...
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}"
DeleteRegKey HKLM "SOFTWARE\${APPNAME}"

; Delete self
Delete "$INSTDIR\uninstall.exe"

; Delete Shortcuts
Delete "$SMPROGRAMS\My App\My App.lnk"
Delete "$SMPROGRAMS\My App\Uninstall.lnk"
Delete "$DESKTOP\My App.lnk"
Delete "$QUICKLAUNCH\My App.lnk"

; Clean up My App
Delete "$INSTDIR\MyApp.exe"

; Clean up Source
Delete "$INSTDIR\src\MyApp.dsp"
Delete "$INSTDIR\src\MyAppAbout.cpp"
Delete "$INSTDIR\src\MyAppAbout.h"
Delete "$INSTDIR\src\license.txt"
Delete "$INSTDIR\src\MyApp.dsw"
Delete "$INSTDIR\src\MyApp.ico"
Delete "$INSTDIR\src\MyApp.nsi"
Delete "$INSTDIR\src\MyApp.rc"
Delete "$INSTDIR\src\MyAppapp.cpp"
Delete "$INSTDIR\src\MyAppapp.h"
Delete "$INSTDIR\src\MyAppfrm.cpp"
Delete "$INSTDIR\src\MyAppfrm.h"
Delete "$INSTDIR\src\MyApplistbox.cpp"
Delete "$INSTDIR\src\MyApplistbox.h"
Delete "$INSTDIR\src\MyAppprefdlg.cpp"
Delete "$INSTDIR\src\MyAppprefdlg.h"
Delete "$INSTDIR\src\readme.txt"
Delete "$INSTDIR\src\resource.h"
Delete "$INSTDIR\src\todo.txt"
Delete "$INSTDIR\src\wxHyperlinksCtrl.cpp"
Delete "$INSTDIR\src\wxHyperlinksCtrl.h"

; Remove remaining directories
RMDir "$SMPROGRAMS\My App"
RMDir "$INSTDIR\src\"
RMDir "$INSTDIR\"

SectionEnd

BrandingText "My App"

; eof


Originally posted by kolpotoru
I have a similar question i have two Installation Type Typical &
Portable and when typical installation is selected the default
installation dir will be $PROGRAMFILES\My Program & if portable
installation type is selected then default installation dir will be
$EXEDIR\My Program please help. I am attaching the script Please Help.
I don't see anything about a custom page so I don't see how this is a similar question, anyway, add a PRE callback to the directory page or a LEAVE callback to the component page where you set $instdir based on the users selection...

Please give some example.


Originally posted by kolpotoru
Please give some example.
Please attempt to figure it out on your own first, try reading about the page instruction in the manual...