I customized the directory destination folder text using the below code snippet in English.nsh file
!define MUI_TEXT_DIRECTORY_TITLE "Destination Folder"
!define MUI_TEXT_DIRECTORY_SUBTITLE "Click Install to install to the default folder or click Browse to choose another"
But I need to change the highlighted text that is showing as "Destination Folder" to "Install EMR to:"
Here the title should be as it is like how it is showing ("Destination Folder")
How to set the highlighted text (Destination Folder) to different text ("Install EMR to:")?
I followed the below link to fix the issue but even with that also i am getting the "Destination Folder" text two times.
Change the text of install folder page in NSIS
Below is my complete code:
CustomEngilish.nsh
!define MUI_TEXT_DIRECTORY_TITLE "Destination Folder"
!define MUI_TEXT_DIRECTORY_SUBTITLE "Click Install to install to the default folder or click Browse to choose another"
!define MUI_DIRECTORYPAGE_TEXT_TOP "Install EMR to:"
!define MUI_DIRECTORYPAGE_TEXT_DESTINATION "Install EMR to:"
!insertmacro MUI_LANGUAGE "English"
Mysetup.nsi
!define MUI_PAGE_CUSTOMFUNCTION_SHOW MyDirectoryShowCallback
!insertmacro MUI_PAGE_DIRECTORY
!include "CustomEnglish.nsh"
Function MyDirectoryShowCallback
StrCpy $PageId 3
SendMessage $mui.DirectoryPage.Text ${WM_SETTEXT} 0 "STR:$(MUI_TEXT_DIRECTORY_TITLE)"
SendMessage $mui.DirectoryPage.Text ${WM_SETTEXT} 0 "STR:$(MUI_TEXT_DIRECTORY_SUBTITLE)"
SendMessage $mui.DirectoryPage.Text ${WM_SETTEXT} 0 "STR:$(MUI_DIRECTORYPAGE_TEXT_TOP)"
SendMessage $mui.DirectoryPage.Text ${WM_SETTEXT} 0 "STR:$(MUI_DIRECTORYPAGE_TEXT_DESTINATION)"
FunctionEnd
MUI_TEXT_DIRECTORY_TITLE is the text in the top header, you want MUI_DIRECTORYPAGE_TEXT_TOP and it needs to point to a custom language string when using multiple languages:
!include "MUI2.nsh"
!insertmacro MUI_PAGE_WELCOME
!define MUI_DIRECTORYPAGE_TEXT_TOP $(mydirtoptext)
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
; CustomSwedish.nsh:
!insertmacro MUI_LANGUAGE "Swedish"
LangString mydirtoptext ${LANG_SWEDISH} "Swedish bork bork"
; CustomEnglish.nsh:
!insertmacro MUI_LANGUAGE "English"
LangString mydirtoptext ${LANG_ENGLISH} "English blah blah"
In your screenshot the top area is gray but it should normally be white, this often indicates a problem with the order of your MUI_PAGE and MUI_LANGUAGE macros. All languages must come after the pages.
Related
As i am working with the NSIS code, i was trying to make two different buttons for restart & restart later in NSIS. Based on the nsis Docuementaion
we need to use following commands(MUI_FINISHPAGE_TEXT_REBOOTNOW,MUI_FINISHPAGE_TEXT_REBOOTLATER)
But i was getting an error called "macro named MUI_FINISHPAGE_TEXT_REBOOTNOW. not found". Could you plese let me know how can we do this tricky task.
!define MUI_FINISHPAGE_TEXT_REBOOTNOW "Yes, restart the computer now"
!define MUI_FINISHPAGE_TEXT_REBOOTLATER "No, I will restart the computer later"
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_FINISHPAGE_TEXT_REBOOTNOW
!insertmacro MUI_FINISHPAGE_TEXT_REBOOTLATER
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
; MUI end ------
Section test
SectionEnd
Those are defines to customize the page, not macros you can call.
!include MUI2.nsh
!insertmacro MUI_PAGE_INSTFILES
!define MUI_FINISHPAGE_REBOOTLATER_DEFAULT ; Make "later" the default option
!define MUI_FINISHPAGE_TEXT_REBOOTNOW "Reboot now!!!!" ; Custom text
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_LANGUAGE English
Section
Sleep 2222
SetRebootFlag True # Pretend we did something that requires a reboot
SectionEnd
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 have two MUI_PAGE_DIRECTORY pages. The first stores the entered data to the default, $INSTDIR. What I would like to do is copy the value in $INSTDIR to the defined var $DataDir so that before the second directory page is displayed, $DataDir becomes $INSTDIR\Data. When the second page is displayed I would like the default value to be $INSTDIR\Data.
Is this possible?
InstallDir $ProgramFiles\MyApp
Var DataDir
!include MUI2.nsh
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE InstDirPageLeave
!insertmacro MUI_PAGE_DIRECTORY
!define MUI_DIRECTORYPAGE_VARIABLE $DataDir
!define MUI_DIRECTORYPAGE_TEXT_TOP "Choose Data directory for bla bla bla..."
!define MUI_DIRECTORYPAGE_TEXT_DESTINATION "Data Directory:"
!define MUI_PAGE_CUSTOMFUNCTION_SHOW DataDirShowPage
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE English
Function InstDirPageLeave
StrCpy $DataDir "$InstDir\Data"
FunctionEnd
Function DataDirShowPage
!insertmacro MUI_HEADER_TEXT "Foo" "Bar"
FunctionEnd
Section
DetailPrint $InstDir
DetailPrint $DataDir
SectionEnd
What are you trying to achieve?
If you want to install some files into two separate locations use MUI_PAGE_DIRECTORY and custom nsDialogs page (with browse folder button) so user can pick up two directories.
If your location is always $INSTDIR and second is somewhere inside it ($INSTDIR\some\data\path) then you only need to append your inside path to $INSTDIR - there is no need to show dialog twice and select path twice.
I have an NSIS installer that has the start menu folders hard-coded using this code...
Var SMDir ;Start menu folder
!insertmacro MUI_PAGE_STARTMENU 0 $SMDir
Section -StartMenu
!insertmacro MUI_STARTMENU_WRITE_BEGIN 0
CreateDirectory "$SMPrograms\MY Program\My Folder"
CreateShortCut "$DESKTOP\My Program" "$INSTDIR\start.exe"
CreateShortCut "$SMPROGRAMS\MY Program\My Shortcut.lnk" "$INSTDIR\start.exe"
CreateShortCut "$SMPROGRAMS\My Program\Uninstall.lnk" "$INSTDIR\uninstall.exe"
This all works apart from on the 'Choose Start Menu Folder' it doesn't let me change the default installation directory.
Is there a way to fix this or alternatively how can I skip this page but still trigger the StartMenu section?
If you don't want a startmenu selection page at all just remove !insertmacro MUI_PAGE_STARTMENU ... and the two !insertmacro MUI_STARTMENU_* macros in the -StartMenu section.
If you want to allow the user to choose the directory then you must use the variable and not hardcode the path:
outfile test.exe
name "SM Test"
requestexecutionlevel user ;Single user/"Just me" installer
!define MUI_COMPONENTSPAGE_NODESC
!include mui2.nsh
Var SMDir ;Start menu folder
!insertmacro MUI_PAGE_COMPONENTS
;!define MUI_STARTMENUPAGE_DEFAULTFOLDER "MY Program" ;Default, name is used if not defined
!insertmacro MUI_PAGE_STARTMENU 0 $SMDir
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE English
Section -StartMenu
!insertmacro MUI_STARTMENU_WRITE_BEGIN 0 ;This macro sets $SMDir and skips to MUI_STARTMENU_WRITE_END if the "Don't create shortcuts" checkbox is checked...
CreateDirectory "$SMPrograms\$SMDir"
CreateShortCut "$SMPROGRAMS\$SMDir\Myapp.lnk" "$INSTDIR\start.exe"
!insertmacro MUI_STARTMENU_WRITE_END
SectionEnd
Section "Desktop Shortcut"
CreateShortCut "$DESKTOP\Myapp.lnk" "$INSTDIR\start.exe"
SectionEnd
(If you are installing as administrator then you should call SetShellVarContext all before accessing $SMPrograms and you should probably not create a desktop shortcut)