I'm trying to add a checkbox to the welcome screen of my NSIS uninstaller, but I'm having trouble finding an example. From the documentation for MUI2 I can't find any custom functions that can be run on the welcome page.
It looks like the finish page is more easy to customize based on the documentation and other answers I've found.
Is there a way to customize the Welcome Page? If not, what are the other options for accomplishing the intent?
The MUI(1) documentation you linked to has a note about how you can customize the welcome page in the pre/show callbacks. With MUI2 you can add controls in the show callback. See the nsDialogs documentation for more information about these custom controls...
!include MUI2.nsh
!insertmacro MUI_PAGE_INSTFILES
!define MUI_PAGE_CUSTOMFUNCTION_SHOW un.ModifyUnWelcome
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE un.LeaveUnWelcome
!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_LANGUAGE English
Var mycheckbox ; You could just store the HWND in $1 etc if you don't want this extra variable
Function un.ModifyUnWelcome
${NSD_CreateCheckbox} 120u -18u 50% 12u "Do something special"
Pop $mycheckbox
SetCtlColors $mycheckbox "" ${MUI_BGCOLOR}
${NSD_Check} $mycheckbox ; Check it by default
FunctionEnd
Function un.LeaveUnWelcome
${NSD_GetState} $mycheckbox $0
${If} $0 <> 0
MessageBox mb_ok "I'm special"
${EndIf}
FunctionEnd
Section testuninstaller
Initpluginsdir
WriteUninstaller "$pluginsdir\u.exe"
ExecWait '"$pluginsdir\u.exe" _?=$pluginsdir'
Sectionend
Related
I am beginner in NSIS, and I want to display the custom text in MUI_PAGE_INSTFILES page as I have two options in Components page 1. Installation and 2. UnInstallation.
So when I choose Below options I am expecting the corresponding text in MUI_PAGE_INSTFILES page.
For Installation Option the text should be "Installation completed"
For UnInstallation Option the text should be "UnInstallation Completed"
Thanks in advance for your help on this.
The CompletedText attribute supports variables:
var mycompletedtext
var myfinishsubtext
CompletedText $mycompletedtext
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_COMPONENTS
!define MUI_INSTFILESPAGE_FINISHHEADER_TEXT "$mycompletedtext"
!define MUI_INSTFILESPAGE_FINISHHEADER_SUBTEXT "$myfinishsubtext"
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
Section Installer
StrCpy $mycompletedtext "Installation completed"
StrCpy $myfinishsubtext "Something something"
SectionEnd
Section Uninstaller
StrCpy $mycompletedtext "UnInstallation Completed"
StrCpy $myfinishsubtext "Bye bye"
SectionEnd
I understand that NSIS uses the installer icon (or MUI_ICON) as the header image by default. And that using MUI_HEADERIMAGE without specifying MUI_HEADERIMAGE_BITMAP uses the default Contrib\Graphics\Header\nsis.bmp
But is it possible to not display a header image altogether? (Aside from the option of specifying a blank (all-white) image as MUI_HEADERIMAGE_BITMAP)
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_RIGHT
!define MUI_CUSTOMFUNCTION_GUIINIT HideHeaderImage
!include MUI2.nsh
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE English
Function HideHeaderImage
!if "${MUI_SYSVERSION}" >= 2.0
ShowWindow $mui.Header.Image 0
!else
GetDlgItem $0 $hwndParent 0x416
ShowWindow $0 0
!endif
FunctionEnd
Alternatively you could edit one of the UIs in ${NSISDIR}\Contrib\UIs\modern*.exe with Resource Hacker to move the image control offscreen and then use MUI_UI or MUI_UI_HEADERIMAGE in your script to select your new UI file.
Can you show what function HideHeaderImage would look like for
!define MUI_WELCOMEFINISHPAGE_BITMAP "leftside.bmp"
I've done some research on customizing NSIS uninstaller pages and had some success with the Welcome and Finish pages.
However I'm having trouble using the same template as I did on the Welcome page with the Confirm page. If I add any control using nsDialogs with a non-zero height value, all of the existing controls (apart from the header and the buttons) on the Confirm page disappear.
Here is my code (it successfully updates the button name but will remove all other controls on that page)
!include MUI2.nsh
OutFile "CustomUninstaller.exe"
InstallDir "C:\Program Files (x86)\NSIS\Examples\CustomFinish"
!define APPNAME "Testing"
Name "${APPNAME}"
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_UNPAGE_WELCOME
!define MUI_PAGE_CUSTOMFUNCTION_SHOW un.ModifyUnConfirm ; My custom function for the Confirm page
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH
!insertmacro MUI_LANGUAGE "English"
Function un.ModifyUnConfirm
# Change "Uninstall" button to say "Continue" on uninstaller confirmation page
GetDlgItem $0 $HWNDPARENT 1
SendMessage $0 ${WM_SETTEXT} 0 "STR:Continue"
# Add new label. If these three lines are commented out, I see the regular controls of this page show up.
# The position, color and background of the label don't seem to matter
${NSD_CreateLabel} 50% 50% 100% 10u "Testing!!!"
Pop $0
SetCtlColors $0 "" ${MUI_BGCOLOR}
FunctionEnd
Section TestUninstaller
WriteUninstaller "$INSTDIR\unCustomUninstaller.exe"
ExecWait "$INSTDIR\unCustomUninstaller.exe"
Sectionend
Questions:
Does anyone know why the controls disappear?
What do I need to do to successfully add a control to this page?
MUI_UNPAGE_CONFIRM is not a nsDialogs page!
To change this dialog you can use the ChangeUI command.
You can also add controls at runtime but only by using the system plugin:
Function un.ModifyUnConfirm
FindWindow $1 "#32770" "" $HWNDPARENT ; Find inner dialog
System::Call 'USER32::CreateWindowEx(i${__NSD_Label_EXSTYLE},t"${__NSD_Label_CLASS}",t "Testing!!!",i${__NSD_Label_STYLE},i 50,i 100,i 400, i 25,i$1,i0,i0,i0)i.s'
Pop $0
SendMessage $HWNDPARENT ${WM_GETFONT} 0 0 $1
SendMessage $0 ${WM_SETFONT} $1 1
SetCtlColors $0 "" ${MUI_BGCOLOR} ; This is the wrong color to use...
FunctionEnd
I am finding it difficult to change the selection in the components page of nsis.
The requirement is during installation i get a license agreement page ,if the user agrees then he/she will click on I AGREE ,after the user clicks on I AGREE ,i want to know on which OS the
setup is being installed that is it can be either on a Windows Embedded OS or WinXp/Win7.
So if it is Windows Embedded OS i want to change the installation package and if it is not Windows Embedded OS then the installation package will be different.
I am using MUI ver1 not MUI2 in my project.
Please let me know how this can be achieved.
To test for the OS where the setup is running, you can use macros defined Winver.nsh with those provided with LogicLib.nsh to make elegant tests like this
;Dont't forget to include
!include "LogicLib.nsh" # use of various logic statements
!include "WinVer.nsh" # LogicLib extension for OS tests
A platform test example:
${if} ${AtLeastWin95}
${AndIf} ${AtMostWinME}
;here we are on a pre-win2k
;do something
${elseIf} ${isWin2008}
${orIf} ${AtLeastWin2008R2}
;this is post-win7
;do other thing
${endif}
To change at runtime the components to install, you can use the macros from Sections.nsh:
;if you have
Section "Sample Database" SecApplicationDB
;...
SectionEnd
;you can select or un select by code:
!insertmacro SelectSection ${SecApplicationDB}
;or
!insertmacro UnselectSection ${SecApplicationDB}
WinVer.nsh does not support checking for Embedded NT but you can perform the check yourself:
!include Sections.nsh
!include MUI.nsh
!ifndef VER_SUITE_EMBEDDEDNT
!define VER_SUITE_EMBEDDEDNT 0x00000040
!endif
!insertmacro MUI_PAGE_LICENSE "${__FILE__}"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE English
Section "Embedded" SID_EMBED
SectionIn RO
SectionEnd
Section "Normal" SID_NORMAL
SectionIn RO
SectionEnd
Function .onInit
System::Call '*(i156,&i152)i.r1'
System::Call 'KERNEL32::GetVersionExA(ir1)'
System::Call '*$1(&i152,&i2.r2)'
System::Free $1
IntOp $2 $2 & ${VER_SUITE_EMBEDDEDNT}
${If} $2 <> 0
!insertmacro SelectSection ${SID_EMBED}
!insertmacro UnselectSection ${SID_NORMAL}
${Else}
!insertmacro UnselectSection ${SID_EMBED}
!insertmacro SelectSection ${SID_NORMAL}
${EndIf}
FunctionEnd
Does anyone have experience with the NSIS Scroll License Plugin?
I am trying to get the scroll license plugin to force a scroll to the end of a EULA. I have the following lines of code included (see below); the problem I am running into is the Welcome Screen has the next button greyed out so I cant even get to the license page with this plugin :( Any ideas on this one?
Thanks much!
Defines
!define MUI_PAGE_CUSTOMFUNCTION_SHOW LicenseShow
INSERTMACROS
!insertmacro MUI_PAGE_LICENSE mylicense.txt
!insertmacro MUI_LANGUAGE English
Section -Main SEC0000
Lots of files
SectionEnd
Functions
LicenseForceSelection checkbox
Function LicenseShow
ScrollLicense::Set /NOUNLOAD
FunctionEnd
Function .onGUIEnd
ScrollLicense::Unload
FunctionEnd
You are missing a number of things in the code you provided to let us test your code. Note also that you need at least one section.
Here is a minimal running sample :
!include "MUI.nsh"
Name "ScrollLicense Test"
OutFile "ScrollLicense.exe"
!define MUI_PAGE_CUSTOMFUNCTION_SHOW LicenseShow
!insertmacro MUI_PAGE_LICENSE mylicense.txt
!insertmacro MUI_LANGUAGE English
LicenseForceSelection checkbox
Function LicenseShow
ScrollLicense::Set /NOUNLOAD
FunctionEnd
Function .onGUIEnd
ScrollLicense::Unload
FunctionEnd
Section "A Section"
;some things to install
;...
SectionEnd