NSIS Custom Page with Custom Header Text - nsis

I am creating a custom page and trying to change the the different page areas, but cant figure out how I have tried several thing and in different spots.
here are the areas I am looking to chance (And I can on like the license page but cant figure out the code for custom pages)
!define MUI_LICENSEPAGE_TEXT_TOP "Change Log of ${PRODUCT_NAME} v${PRODUCT_VERSION}"
!define MUI_LICENSEPAGE_TEXT_BOTTOM " "
!define MUI_LICENSEPAGE_BUTTON "Next" # or "Next" if you have other pages between the changelog and the InstFiles page
!define MUI_PAGE_HEADER_TEXT "Change Log"
!define MUI_PAGE_HEADER_SUBTEXT "Overview of changes in Drive Content"
here is the code I am working with
!define FolderDocs "Included\Docs"
!define FolderImages "Included\Images"
!define FolderAudio "Included\Audio"
!define FolderData "Included\Data"
!define DocLicense "License.txt"
!define DocChangeLog "ChangeLog.txt"
!define DocMustRead "MustRead.txt"
!define ImageIcon "Icon.ico"
!define ImageHDR "HDR.bmp"
!define ImageWF "WF.bmp"
!define ImageSplash "Splash.bmp"
!define PRODUCT_NAME "Test"
!define PRODUCT_VERSION "1.0"
!define MUI_ICON ".\${FolderImages}\${ImageIcon}"
Icon ".\${FolderImages}\${ImageIcon}"
!include WinVer.nsh
!include LogicLib.nsh
!include x64.nsh
!include FileFunc.nsh
!include MUI.nsh
!include WinMessages.nsh
!include InstallOptions.nsh
!include Sections.nsh
!include nsDialogs.nsh
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP ".\${FolderImages}\${ImageHDR}"
!define MUI_WELCOMEFINISHPAGE_BITMAP ".\${FolderImages}\${ImageWF}"
!define MUI_ABORTWARNING
!define MUI_PAGE_HEADER_TEXT "Change Log" #DOES NOT WORK
!define MUI_PAGE_HEADER_SUBTEXT "Overview of changes in Drive Content" #DOES NOT WORK
Page custom SetCustom ValidateCustom
!insertmacro MUI_LANGUAGE "English"

See the "Custom pages" section of the readme?
!include MUI2.nsh
...
Page Custom MyPageCreate
!insertmacro MUI_LANGUAGE "English"
Function MyPageCreate
!insertmacro MUI_HEADER_TEXT "Blah" "blah blah blah"
nsDialogs::...
FunctionEnd

Related

How to set the Focus to a License Agreement Checkbox control using NSIS

I wanted to set the by default Focus to the "License Agreement" checkbox in the License Agreement Page using NSIS. And then the taborder should work.
Please help me how to set the focus?
Below is my code snippet:
!include LogicLib.nsh
!define MUI_TEXT_WELCOME_INFO_TITLE $(welcometitle)
!define MUI_TEXT_WELCOME_INFO_TEXT $(welcometext)
!insertmacro MUI_PAGE_WELCOME
!define MUI_LICENSEPAGE_CHECKBOX ""
!define MUI_INNERTEXT_LICENSE_BOTTOM ""
!define MUI_INNERTEXT_LICENSE_TOP ""
!define MUI_INNERTEXT_LICENSE_BOTTOM_CHECKBOX ""
!define MUI_TEXT_LICENSE_TITLE $(licensetitle)
!define MUI_TEXT_LICENSE_SUBTITLE $(licensesubtitle)
!define MUI_LICENSEPAGE_CHECKBOX_TEXT $(licensecheckboxtext)
!insertmacro MUI_PAGE_LICENSE "C:\Program Files (x86)\NSIS\Docs\Modern UI 2\license.txt"
!define MUI_DIRECTORYPAGE_TEXT_TOP $(mydirtoptext)
!define MUI_TEXT_DIRECTORY_TITLE $(mydirtitle)
!define MUI_TEXT_DIRECTORY_SUBTITLE $(mydirsubtitle)
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!define MUI_TEXT_FINISH_INFO_TITLE $(Finishpagetitle)
!define MUI_TEXT_FINISH_INFO_TEXT $(Finishpagesubtitle)
!define MUI_FINISHPAGE_RUN ""
!define MUI_FINISHPAGE_RUN_TEXT $(FinishonlineReg)
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_INSTFILES
;--------------------------------
!insertmacro MUI_LANGUAGE "English"
; The stuff to install
Section "My TestApp (required)"
SectionEnd
The Windows UI guidelines says:
For keyboard navigation, tab order should flow in a logical order, generally from left to right, top to bottom.
but if you think you must force then you can do this:
!include WinMessages.nsh
!include MUI2.nsh
!insertmacro MUI_PAGE_WELCOME
!define MUI_LICENSEPAGE_CHECKBOX ""
!define MUI_PAGE_CUSTOMFUNCTION_SHOW myForceLicenseFocus
!insertmacro MUI_PAGE_LICENSE "${__FILE__}"
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE English
Function myForceLicenseFocus
!if ${MUI_SYSVERSION} >= 2.0
FindWindow $0 "BUTTON" "" $mui.LicensePage
!else
FindWindow $0 "#32770" "" $hWndParent
FindWindow $0 "BUTTON" "" $0
!endif
System::Call 'USER32::SetFocus(pr0)'
!define /ifndef WM_CHANGEUISTATE 0x127
System::Call 'USER32::PostMessage(pr0,i${WM_CHANGEUISTATE},p0x30002,p0)' ; This forces the checkbox to display the focus rectangle
System::Call 'USER32::SetWindowPos(pr0,p0,i,i,i,i,i0x13)' ; Change tab order
FunctionEnd

How to change MUI_INSTFILESPAGE_FINISHHEADER_SUBTEXT if exists two MUI_PAGE_INSTFILES

I have managed to customize the message shown in the title / subtitle after installation:
!define APP_NAME 'Test15'
name ${APP_NAME}
outfile '${APP_NAME}.exe'
showinstdetails show
InstallDir '$PROGRAMFILES\${APP_NAME}'
!include 'mui.nsh'
Var CompletedText
CompletedText $CompletedText
Var MUI_HeaderText
Var MUI_HeaderSubText
!define MUI_INSTFILESPAGE_FINISHHEADER_TEXT "$MUI_HeaderText"
!define MUI_INSTFILESPAGE_FINISHHEADER_SUBTEXT "$MUI_HeaderSubText"
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
Section "One"
MessageBox MB_OK "Section One"
SectionEnd
Section -"Post"
;MessageBox MB_OK "Section Post"
StrCpy $CompletedText "My custom text"
StrCpy $MUI_HeaderText "My custom header text"
StrCpy $MUI_HeaderSubText "My custom header subText"
;MessageBox MB_OK "OUTING Section Post"
SectionEnd
My problem is that when I need to add a second part installation (it is a new mandatory requirement), and then not get modify / customize messages title / subtitle shown at the end:
!define APP_NAME 'Test15'
name ${APP_NAME}
outfile '${APP_NAME}.exe'
showinstdetails show
InstallDir '$PROGRAMFILES\${APP_NAME}'
!include 'mui.nsh'
Var CompletedText
CompletedText $CompletedText
Var MUI_HeaderText
Var MUI_HeaderSubText
!define MUI_INSTFILESPAGE_FINISHHEADER_TEXT "$MUI_HeaderText"
!define MUI_INSTFILESPAGE_FINISHHEADER_SUBTEXT "$MUI_HeaderSubText"
!insertmacro MUI_PAGE_INSTFILES
;This my second part instalation!!
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
Section "One"
MessageBox MB_OK "Section One"
SectionEnd
Section -"Post"
;MessageBox MB_OK "Section Post"
StrCpy $CompletedText "My custom text"
StrCpy $MUI_HeaderText "My custom header text"
StrCpy $MUI_HeaderSubText "My custom header subText"
;MessageBox MB_OK "OUTING Section Post"
SectionEnd
Now, the same message is always displayed at the end for Title/Subtitle: "Installation Complete" // "Setup was completed successfully.". Nevertheless, the 'completed' text value is modified successfully ("My custom text").
Please, can anyone help me?
Thanks in advance!
If you read the MUI documentation carefully you will find this in the "Page settings" section:
Page settings apply to a single page and should be set before inserting a page macro. The same settings can be used for installer and uninstaller pages. You have to repeat the setting if you want it to apply to multiple pages.
Only the defines listed under "Interface settings" are global.
!include MUI.nsh
!define MUI_PAGE_HEADER_TEXT "Install page #1"
!define MUI_PAGE_HEADER_SUBTEXT "Foo foo foo"
!define MUI_INSTFILESPAGE_FINISHHEADER_TEXT "Did part 1"
!define MUI_INSTFILESPAGE_FINISHHEADER_SUBTEXT "..."
!insertmacro MUI_PAGE_INSTFILES
!define MUI_PAGE_HEADER_TEXT "Install page #2"
!define MUI_PAGE_HEADER_SUBTEXT "Bar bar bar!"
!define MUI_INSTFILESPAGE_FINISHHEADER_TEXT "All done"
!define MUI_INSTFILESPAGE_FINISHHEADER_SUBTEXT "ZZZzzz.."
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"

Changing my NSIS installer Application Version

I am updating an existing application and want to set the new Application Version Number. I used the !define VERSION "Version Number" but the application still retains the previous Version number. I have also been going through NSIS SourceForge in search of the solution but none that could show and then change the Version Number. The Version Number i want to show is 2.1.1259.1 but it keeps returning the old 2.0.236.1258
The code looks as follows:
; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "Application Name"
!define PRODUCT_VERSION "2.1.1259.1"
!define VERSION "2.1.1259.1"
!define PRODUCT_PUBLISHER "CompanyName"
!define PRODUCT_WEB_SITE "http://www.CompanyName.com"
!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\${PRODUCT_NAME}"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"
Var InDebugMode
Var SQLAccountType
Var SQLUSER
Var SQLPASSWORD
Var SQLSERVER
Var RunInstalls
Var CurrentStep
Var InstallDB
Var SupportedVersions
Var SetupFileName
Var InstallsPath
; MUI 1.67 compatible ------
!include "MUI.nsh"
!include "LogicLib.nsh"
!include "Source\Scripts\DotNetDetect.nsh"
!include "Source\Scripts\WriteToFile.nsh"
!include "Source\Scripts\Page_InstallerPage.nsh"
!include "Source\Scripts\TrimString.nsh"
!include WinMessages.nsh
!include "LogicLib.nsh"
!include "x64.nsh"
!include "Source\Scripts\StrRep.nsh"
!include "Source\Scripts\InstallerControl.nsh"
!include "Source\Scripts\ReplaceInFile.nsh"
!include "Source\Scripts\Debug.nsh"
!include "Source\Scripts\VersionCompare.nsh"
!include "Source\Scripts\CheckWindows.nsh"
!include "Source\Scripts\CheckDotNet4.nsh"
!include "Source\Scripts\CreateShortcuts.nsh"
!include "Source\Scripts\InstallFonts.nsh"
; MUI Settings
!define MUI_ABORTWARNING
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"
!define UMUI_HEADERIMAGE_BMP "ilaundry-logo.bmp"
!define MUI_BGCOLOR 0xFFFFFF
!define MUI_PAGE_CUSTOMFUNCTION_PRE SkipOnRestart_Licence
!insertmacro MUI_PAGE_LICENSE "Source\Scripts\TAC.TXT"
Page custom Installer_Page_Start Installer_Page_Leave
!include "Source\Scripts\InstallCrystalReports.nsh"
!include "Source\Scripts\UpdateConfigFile.nsh"
!include "Source\Scripts\InstallSqlServer.nsh"
!include "Source\Scripts\InstallDatabase.nsh"
!include "Source\Scripts\InstallDigitalPersona.nsh"
!include "Source\Scripts\InstallAccessDBEngine.nsh"
!include "Source\Scripts\InstallApplication.nsh"
!include "Source\Scripts\InstallBackup.nsh"
!include "Source\Scripts\UninstallSqlServer.nsh"
!include "Source\Scripts\SplashController.nsh"
!define MUI_PAGE_CUSTOMFUNCTION_PRE Skip_Finish
!insertmacro MUI_PAGE_FINISH
; Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES
; Language files
!insertmacro MUI_LANGUAGE "English"
; MUI end ------
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
InstallDir "$PROGRAMFILES\ApplicationName"
InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
ShowInstDetails show
ShowUnInstDetails show
Function SkipOnRestart_Licence
${IfNot} $CurrentStep == "new"
Abort
${EndIf}
FunctionEnd
Function Skip_Finish
Abort
FunctionEnd
Function SharedOnInt
InitPluginsDir
File /oname=$PLUGINSDIR\InstallScreen.ini "Source\Scripts\InstallScreen.ini"
StrCpy $InDebugMode 'True'
StrCpy $RunInstalls 'True'
strcpy $StepBeforeReboot "none"
CALL LoadCurrentStep
PUSH 'onInt - Start'
PUSH ''
CALL DumpValues
SetRegView 64
DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce"
SetRegView 32
#call uninstallSQLServer
writeUninstaller $INSTDIR\uninstaller.exe
PUSH 'onInt - End'
PUSH ''
CALL DumpValues
FunctionEnd
Function .onGUIEnd
;Push '$INSTDIR\LogDump.txt'
;Call DumpLog
FunctionEnd
Var UnRegValue
# create a section to define what the uninstaller does.
# the section will always be named "Uninstall"
section "Uninstall"
# Always delete uninstaller first
delete $INSTDIR\uninstaller.exe
ReadRegStr $UnRegValue HKLM "SOFTWARE\${PRODUCT_PUBLISHER}\${PRODUCT_NAME}\${PRODUCT_VERSION}" "InstalledSQL"
${If} $UnRegValue == "true"
call un.uninstallSQLServer
${EndIf}
ReadRegStr $UnRegValue HKLM "SOFTWARE\${PRODUCT_PUBLISHER}\${PRODUCT_NAME}\${PRODUCT_VERSION}" "InstalledCrystalReports"
${If} $UnRegValue == "true"
call un.uninstallSQLServer
${EndIf}
;StrCmp $UnRegValue "true" UninstallSQLServer
sectionEnd
I realize there are a lot of !include but to save question space I left them out for now but if you think the problem may be hidden in one of them I will add that specific .nsh file. Any help would be appreciated in the end.
PRODUCT_VERSION is just a define with no special meaning to the compiler, the VI* attributes are used to set the version information in NSIS.
The version information is stored both in a binary block and as readable strings. The binary block information is controlled by the VIProductVersion and VIFileVersion attributes and the string information is set with VIAddVersionKey. These attributes are not even present in the code you posted so they must be in one of the .nsh files? Perhaps you are setting them in more than one place?
It should look something like this:
!define PRODUCT_VERSION "2.1.1259.1"
!define VERSION "2.1.1259.1"
VIProductVersion "${PRODUCT_VERSION}"
VIFileVersion "${VERSION}"
VIAddVersionKey "FileVersion" "${VERSION}"
VIAddVersionKey "LegalCopyright" "(C) Blah blah Inc."
VIAddVersionKey "FileDescription" "Blah blah blergh fancy app"
If you are still getting the wrong values after verifying that you are not setting the information in multiple places then perhaps Explorer is caching the information. You can inspect the raw version information with a tool like Resource Hacker...

NSIS - add CreateText to MUI FINISH PAGE

I have an NSIS installer which at completion of the install sends an e-mail with a couple different logs attached. I'd like to allow the user to add their e-mail address to receive the e-mail and I'd like for them to enter it on the finish page because it seem most appropriate. How can I add a text box on the finish page for the user to enter their e-mail address into?
Here is my current finish page:
;Finish page
!Define MUI_FINISHPAGE_RUN
!Define MUI_FINISHPAGE_RUN_TEXT 'Open Install Log'
!Define MUI_FINISHPAGE_RUN_NOTCHECKED
!define MUI_FINISHPAGE_RUN_FUNCTION 'LaunchLog'
!define MUI_FINISHPAGE_LINK 'Click here to visit us at co.com.'
!define MUI_FINISHPAGE_LINK_LOCATION http://www.co.com/
!define MUI_FINISHPAGE_TEXT_LARGE
!define MUI_FINISHPAGE_TEXT "text text text"
!insertmacro MUI_PAGE_FINISH
!include MUI2.nsh ;If you are using MUI v1 you need to replace NSD_* with .ini file commands
!include Logiclib.nsh
...
!ifndef EM_SETCUEBANNER
!define EM_SETCUEBANNER 0x1501 ; NT5 w/Themes & Vista+
!endif
Var EMailEdit
Function CustomizeFinishPage
${NSD_CreateText} 120u 144u 180u 12u ""
Pop $EMailEdit
System::Call 'USER32::SendMessage(i$EMailEdit,i${EM_SETCUEBANNER},i0,w"E-mail address goes here...")'
FunctionEnd
Function SendFinishMail
${NSD_GetText} $EMailEdit $0
${If} $0 == "" ; TODO: Verify address by at least checking for *#*.*
MessageBox mb_iconstop "You must enter a valid address!"
Abort
${EndIf}
MessageBox mb_ok "TODO: Send mail to: $0"
FunctionEnd
...
!insertmacro MUI_PAGE_*
;Finish page
!define MUI_FINISHPAGE_RUN
!define MUI_FINISHPAGE_RUN_TEXT 'Open Install Log'
!define MUI_FINISHPAGE_RUN_NOTCHECKED
!define MUI_FINISHPAGE_RUN_FUNCTION 'LaunchLog'
!define MUI_FINISHPAGE_SHOWREADME "" #Used as our email checkbox
!define MUI_FINISHPAGE_SHOWREADME_TEXT "E-mail me some crap:"
!define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
!define MUI_FINISHPAGE_SHOWREADME_FUNCTION SendFinishMail
!define MUI_FINISHPAGE_LINK 'Click here to visit us at co.com.'
!define MUI_FINISHPAGE_LINK_LOCATION http://www.co.com/
!define MUI_FINISHPAGE_TEXT_LARGE
!define MUI_FINISHPAGE_TEXT "text text text"
!define MUI_PAGE_CUSTOMFUNCTION_SHOW CustomizeFinishPage
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_LANGUAGE English

NSIS Change Header Image Based on Language Selection

I am using NSIS to create an installer. How can I change the header image (MUI_HEADERIMAGE_BITMAP) based on the users language selection at install?
!define MUI_HEADERIMAGE
!define MUI_CUSTOMFUNCTION_GUIINIT myGuiInit
!include MUI2.nsh
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_COMPONENTS
...
!insertmacro MUI_LANGUAGE English
!insertmacro MUI_LANGUAGE Swedish
Function .onInit
!insertmacro MUI_LANGDLL_DISPLAY
FunctionEnd
Function myGUIInit
InitPluginsDir
${If} ${LANG_ENGLISH} = $Language
File "/oname=$PluginsDir\langspecifichdr.bmp" "${NSISDIR}\Contrib\Graphics\Header\orange.bmp"
${Else}
File "/oname=$PluginsDir\langspecifichdr.bmp" "${NSISDIR}\Contrib\Graphics\Header\win.bmp"
${EndIf}
SetBrandingImage /IMGID=1046 "$PluginsDir\langspecifichdr.bmp"
FunctionEnd

Resources