Skip to content
⌘ NSIS Forum Archive

NSIS Conditional Custom Page

9 posts

jt9000#

NSIS Conditional Custom Page

I would like to create a custom page that appears only if the detected OS is 32 bit.
If the OS is 32 bit, the custom page will display a link to download the 32 bit installer, and only has "exit" button available to quit the installer.

Any examples on how this can be done?
So far I have the following snippets that detect the OS and make decisions as to whether to skip the custom page or display it.


;Page showing download link for 32bit if OS is 32bit
Page custom Download32bit

#Custom page function to ask user to download 32bit installer
Function Download32bit
# Check if OS is 64 bit
${If} ${RunningX64}
Goto passOSCheck
${Else}
!insertmacro MUI_HEADER_TEXT $(DOWNLOAD32BIT_TITLE) $(DOWNLOAD32BIT_SUBTITLE)
MessageBox MB_OK "Your Operating System is 32-bit, please download HexSight 32bit installer."
Quit
${EndIf}
passOSCheck:
FunctionEnd

LangString DOWNLOAD32BIT_TITLE ${LANG_ENGLISH} "Download HexSight 32-bit"
LangString DOWNLOAD32BIT_SUBTITLE ${LANG_ENGLISH} "Please visit download 32-bit installer"
p.s. what is the correct method to change the body of the page? I've only found MUI_HEADER_TEXT to change the headers.
LoRd_MuldeR#
And what exactly is your question or problem?

Just put the OS check in the pre-function of the "custom" page and, in that function, call Abort in case you which to skip the page - as you are already doing. Otherwise, when you do not want to skip the page, you setup the custom page as usual. Though, one problem I see with your current "Download32bit" function seems to be that you always call Abort in the end - or do I miss something?

BTW: Please use [CODE] tags when pasting code 😉
jt9000#
I have updated the code to reflect what I currently have. It currently works by having a "pop up message" stating that 32 bit installer should be downloaded.

What I am looking for is something more elegant: a install page that has the download link included in the text body, and the user can click on exit to exit the installer. Is this possible to do?

Thanks 🙂
LoRd_MuldeR#
Why not use something like:


Page custom Download32bitShow Download32bitLeave

Function Download32bitShow
# Skip the custom page, if running on a 64-Bit OS
${IfThen} ${RunningX64} ${|} Abort ${|}

# Set up the custom page here, as you would do normally
[...]
FunctionEnd

Function Download32bitLeave
# Exit installer when leaving the custom page
Quit
FunctionEnd
jt9000#
Thanks LoRd_MuldeR.

My remaining question is how can the body text of the custom page be inserted/edited? I couldn't find any examples online. Is there something similar to !insertmacro MUI_HEADER_TEXT, but for the body of the page?
LoRd_MuldeR#
C'mon! You could at least have a look at the nsDialogs or InstallOptions tutorial 😉
jt9000#
I did look into nsDialogs, but thought there would be something right from MUI.

Thanks again.
LoRd_MuldeR#
Actually MUI2 makes use of the nsDialogs plug-in to create its built-in pages. MUI still used InstallOptions.
jt9000#
I have everything working as I want it to now with nsDialogs!

Thanks again for your patience as I am brand new to NSIS.

Cheers!! 🙂