Introduction NSIS 2 makes it is possible to create installers with a custom user interface. The Modern UI is an interface like the wizards of recent Windows versions. This new interface also features new pages (Welcome, Finish, Start Menu) and a description area on the component selection page. Because of the macro system with support for plugins and the special language files, writing scripts for the Modern UI is easy. Important: Because the Modern UI has its own macro system, its own default settings and a lot of new features, the interface configuration works differently. So you should not use commands like Icon, BrandingText etc. Read this document for more info. Screenshots How to use The Modern UI has a macro system, so most of the code has already been written for you! The easiest way to use the Modern UI is to customize one of the example scripts, but you can also modify an existing script. Note: If you want to add a double quote (") to a Modern UI string, you should always escape it ($\"), because the Modern UI macro's use " to separate parameters. To use the Modern UI in an existing script, you should follow these steps: 1. Include the header file
    !include "MUI.nsh"
MUI.nsh is in the Include directory, so you don't have to specify a path. 2. Define the name and version of your software
    !define MUI_PRODUCT "Your Software"
    !define MUI_VERSION "1.0"
3. Pages Insert the following macro's to set the pages you want to use and the order of the pages. You can insert custom Page commmands between the macro's to add custom pages. More info about custom pages... Example:
    !insertmacro MUI_PAGE_COMPONENTS
Installer Pages MUI_PAGE_WELCOME MUI_PAGE_LICENSE MUI_PAGE_COMPONENTS MUI_PAGE_DIRECTORY MUI_PAGE_STARTMENU MUI_PAGE_INSTFILES MUI_PAGE_FINISH Uninstaller Pages MUI_UNPAGE_CONFIRM MUI_UNPAGE_INSTFILES 4. Defines You can use defines to configure the Modern UI. Most defines (i.e. MUI_COMPONENTSPAGE_SMALLDESC) don't need a value, they are true/false settings. Others (i.e. MUI_FINISHPAGE_RUN) can be used to define a specific value. Parameters are specified in this format: required (option1 | option2) [optional]. You should put all parameters in one string for the define:
    !define MUI_STARTMENUPAGE_NODISABLE ;No value
    !define MUI_FINISHPAGE_RUN "$INSTDIR\Application.exe" ;Value
    !define MUI_INSTALLCOLORS "FFFFFF 000000" ;Multiple parameters
All defines are optional. 4a. General settings License Page Settings MUI_LICENSEPAGE_CHECKBOX Display a checkbox the user has to check to agree with the license terms. MUI_LICENSEPAGE_RADIOBUTTONS Display two radiobuttons to allow the user to choose between accepting the license terms or not. Components Page Settings MUI_COMPONENTSPAGE_SMALLDESC A small description area on the bottom of the page. Use this layout if you have a lot of sections and don't need large descriptions. MUI_COMPONENTSPAGE_NODESC No description area. Start Menu Folder Selection Page Settings If you did not disable the 'Do not create shortcuts' checkbox, put the script code to write the shortcuts between these macro's, because the creation can be disabled by the user:
    !insertmacro MUI_STARTMENU_WRITE_BEGIN
      ...create the shortcuts...
    !insertmacro MUI_STARTMENU_WRITE_END
MUI_STARTMENUPAGE_VARIABLE variable Variable to store the current Start Menu Folder. Default is $9. You cannot use this variable in your script (or you should Push/Pop it). MUI_STARTMENUPAGE_DEFAULTFOLDER folder The default Start Menu Folder. For installers with multiple languages, you can use a language string as value. MUI_STARTMENUPAGE_NODISABLE Do not display the checkbox to disable the creation of Start Menu shortcuts. MUI_STARTMENUPAGE_REGISTRY_ROOT root MUI_STARTMENUPAGE_REGISTRY_KEY key MUI_STARTMENUPAGE_REGISTRY_VALUENAME value_name The registry key to store the Start Menu folder. The page will use it to remember the users preference. You should also use it in the uninstaller to remove the Start Menu folders. Don't forget to remove this key in the uninstaller. In the uninstaller, use these macro's to remove the shortcuts:
    !insertmacro MUI_STARTMENU_DELETE_BEGIN $R0 ;You can also use another variable
      Delete "$SMPROGRAMS\$R0\Your Shortcut.lnk"
    !insertmacro MUI_STARTMENU_DELETE_END
Finish Page Settings MUI_FINISHPAGE_RUN exe_file Application which the user can select to run (using a checkbox). You don't need to put quotes around the filename when it contains spaces. MUI_FINISHPAGE_RUN_PARAMETERS parameters Parameters for the application to run. Don't forget to escape double quotes in the value (use $\"). MUI_FINISHPAGE_RUN_NOTCHECKED Do not check the 'Run program' checkbox by default MUI_FINISHPAGE_SHOWREADME file/url File or website which the user can select to view (using a checkbox). You don't need to put quotes around the filename when it contains spaces. Use $(LANGSTRINGNAME) as value is you want to use a language string. MUI_FINISHPAGE_SHOWREADME_NOTCHECKED Do not check the 'Show Readme' checkbox by default MUI_FINISHPAGE_NOAUTOCLOSE Do not automatically jump to the finish page, to allow the user to check the log. MUI_FINISHPAGE_NOREBOOTSUPPORT Disables support for the page that allows the user to reboot the system. Define this option to save some space if you are not using the /REBOOTOK flag or SetRebootFlag. Other settings MUI_ABORTWARNING Show a message box with a warning (are you sure?) when the user closes the installation. 4b. Interface settings For UI elements that are enabled by default, the default value will be used when a setting has not been defined. MUI_UI ui_file The interface file with the dialog resources. Change this if you have made your own customized UI. Default: ${NSISDIR}\Contrib\UIs\modern.exe MUI_UI_HEADERBITMAP ui_file MUI_UI_HEADERBITMAP_RIGHT ui_file The interface files with the dialog resource IDD_INST that contains a bitmap control and space for the header bitmap. Defaults: ${NSISDIR}\Contrib\UIs\modern-headerbmp.exe, ${NSISDIR}\Contrib\UIs\modern-headerbmpr.exe MUI_UI_SMALLDESCRIPTION MUI_UI_NODESCRIPTION The interface files with a customized dialog resource IDD_SELCOM for a small or no description area. Defaults: {NSISDIR}\Contrib\UIs\modern-smalldesc.exe, {NSISDIR}\Contrib\UIs\modern-nodesc.exe MUI_ICON icon_file The icon of the installer. Default: ${NSISDIR}\Contrib\Icons\modern-install.ico MUI_UNICON icon_file The icon of the uninstaller. Default: ${NSISDIR}\Contrib\Icons\modern-uninstall.ico MUI_LICENSEBKCOLOR color: RRGGBB The background color for the license textbox. Default: /windows MUI_CHECKBITMAP bitmap_file The bitmap with images for the checks of the component select treeview. Default: ${NSISDIR}\Contrib\Icons\modern.bmp MUI_INSTALLCOLORS (/windows | (foreground color: RRGGBB) (background color: RRGGBB)) The colors of the details screen. Use /windows instead of the colors to use the Windows colors (the default). Default: /windows MUI_PROGRESSBAR ("" | colored | smooth) The style of the progress bar. Colored makes it use the MUI_INSTALLCOLORS. Default: smooth MUI_HEADERBITMAP bmp_file Bitmap to display in the white header. With the default DPI, a bitmap with a size 150x57 won't have to be resized. The NSIS Setup uses the ${NSISDIR}\Contrib\Icons\modern-header.bmp bitmap, but can also make one with your own logo. MUI_HEADERBITMAP_RIGHT Display the header image on the right side instead of the left side. MUI_SPECIALINI ini_file InstallOptions INI file for the Welcome and Finish page. Default: ${NSISDIR}\Contrib\Modern UI\ioSpecial.ini MUI_SPECIALBITMAP bmp_file Bitmap for the Welcome and Finish page. Default: ${NSISDIR}\Contrib\Icons\modern-wizard.bmp MUI_BGCOLOR (color: 0xBBGGRR) Background color for the header, Welcome page and Finish page. Default: 0xFFFFFF MUI_RTL_UI Right-to-left interface. 5. Define custom functions (optional) If you want add your own code to functions inserted by the Modern UI (i.e. the .onGUIInit function and the page functions), create your own function and let the Modern UI functions call them.. More info... 6. Insert language files Insert the Modern UI language files for the languages you are using:
    !insertmacro MUI_LANGUAGE "English"
The Modern UI language files load the NLF language files, so you should not use LoadLanguageFile. You don't need to edit the language files if you want to customize some strings. Use defines before you insert the language file:
    !define MUI_BRANDINGTEXT "French Branding Text"
    !insertmacro MUI_LANGUAGE "French"
Have a look at the language files for a complete list of all the string names. You can customize texts that can be set in the Classic UI using the LicenseText, ComponentText, DirText and MiscButtonText commands but are not being changed by the Modern UI using these defines: MUI_BUTTONTEXT_LICENSE text MUI_BUTTONTEXT_BACK text MUI_BUTTONTEXT_NEXT text MUI_BUTTONTEXT_CANCEL text MUI_INNERTEXT_COMPONENTS_SUB1 text MUI_INNERTEXT_COMPONENTS_SUB2 text MUI_TEXT_DIRECTORY_BROWSE text You can also customize the fonts for a language using the following defines: MUI_FONT_HEADER font_name MUI_FONTSIZE_HEADER font_size MUI_FONTSTYLE_HEADER weight [/ITALIC] [/UNDERLINE] [/STRIKE] The font for the title in the header. MUI_FONT_TITLE font_name MUI_FONTSIZE_TITLE font_size MUI_FONTSTYLE_TITLE weight [/ITALIC] [/UNDERLINE] [/STRIKE] The font for the title on the Welcome and Finish page. Language selection dialog If you want the installer to display a language selection dialog (have a look at the MultiLanguage.nsi example), insert the MUI_LANGDLL_DISPLAY macro in .onInit:
    Function .onInit

      !insertmacro MUI_LANGDLL_DISPLAY

    FunctionEnd
To customize the language selection dialog, use these defines: MUI_LANGDLL_WINDOWTITLE text The window title of the language selection dialog. MUI_LANGDLL_INFO text The text on the language selection dialog. MUI_LANGDLL_REGISTRY_ROOT root MUI_LANGDLL_REGISTRY_KEY key MUI_LANGDLL_REGISTRY_VALUENAME value_name The registry key to store the language. The users preference will be remembered. You can also use it in the uninstaller to display the right language. Don't forget to remove this key in the uninstaller. In the uninstaller, insert the MUI_UNGETLANGUAGE macro in un.onInit to get the stored language preference:
    Function un.onInit

      !insertmacro MUI_UNGETLANGUAGE

    FunctionEnd
7. Set the descriptions for the sections Insert the description macro's to set the descriptions for the sections. These descriptions will be displayed on the component selection page, when the users hovers the mouse over a section. If you don't want to use descriptions, use the modern3.exe UI.
    LangString DESC_Section1 ${LANG_ENGLISH} "Description of section 1."
    LangString DESC_Section2 ${LANG_ENGLISH} "Description of section 2."

    !insertmacro MUI_FUNCTIONS_DESCRIPTION_BEGIN
      !insertmacro MUI_DESCRIPTION_TEXT ${Section1} $(DESC_Section1)
      !insertmacro MUI_DESCRIPTION_TEXT ${Section2} $(DESC_Section2)
    !insertmacro MUI_FUNCTIONS_DESCRIPTION_END
Add an extra parameter to the Section command to set the define with the section number:
    Section "Section Name 1" Section1
      ...
    SectionEnd
8. Reserve Files If you are using BZIP2 compression, you might need to insert ReserveFile commands. More info... Custom pages Custom page commands If you want add custom pages to your installer, you should insert your own page commands between the page macro's:
    !insertmacro MUI_PAGE_WELCOME
    Page custom FunctionName ;Custom page
    !insertmacro MUI_COMPONENTS
For the uninstaller:
    !insertmacro MUI_UNPAGE_CONFIRM
    UninstPage custom un.FunctionName ;Custom page
    !insertmacro MUI_UNPAGE_INSTFILES
Call InstallOptions InstallOptions is a plug-in that displays custom pages that you can create using INI files. Have a look at the InstallOptions documentation for info about creating InstallOptions INI files. First, you need to extract your InstallOptions INI File in the .onInit function (un.onInit for the uninstaller) using the MUI_INSTALLOPTIONS_EXTRACT macro:
    Function .onInit
      !insertmacro MUI_INSTALLOPTIONS_EXTRACT "ioFile.ini"
    FunctionEnd
If your INI File is located in another directory, use MUI_INSTALLOPTIONS_EXTRACT_AS. The second parameter is the filename for the Plugins directory. Use this name when inserting the other InstallOptions macro's:
    Function .onInit
      !insertmacro MUI_INSTALLOPTIONS_EXTRACT_AS "..\ioFile.ini" "ioFile.ini"
    FunctionEnd
You can call Instal Options in the function defined with the Page or UninstPage command using the MUI_INSTALLOPTIONS_DISPLAY macro. Use the MUI_HEADER_TEXT macro to set the text in the white box:
    LangString TEXT_IO_TITLE ${LANG_ENGLISH} "Install Options Page Title"
    LangString TEXT_IO_SUBTITLE ${LANG_ENGLISH} "A subtitle"

    Function FunctionName ;FunctionName defined with Page command
      !insertmacro MUI_HEADER_TEXT "$(TEXT_IO_TITLE)" "$(TEXT_IO_SUBTITLE)"
      !insertmacro MUI_INSTALLOPTIONS_DISPLAY "ioFile.ini"
    FunctionEnd
For custom fonts and colors, macro's for the initDialog and show functions of InstallOptions are also available:
    LangString TEXT_IO_TITLE ${LANG_ENGLISH} "Install Options Page Title"
    LangString TEXT_IO_SUBTITLE ${LANG_ENGLISH} "A subtitle"

    Function FunctionName ;FunctionName defined with Page command

      !insertmacro MUI_HEADER_TEXT "$(TEXT_IO_TITLE)" "$(TEXT_IO_SUBTITLE)"

      Push $R0
      Push $R1
      Push $R2

        !insertmacro MUI_INSTALLOPTIONS_INITDIALOG "ioFile.ini"
        Pop $R0 ;HWND of dialog

        GetDlgItem $R1 $R0 1200 ;1200 + Field number - 1

        ;$R1 contains the HWND of the first field
        CreateFont $R2 "Tahoma" 10 700
        SendMessage $R1 ${WM_SETFONT} $R2 0

        !insertmacro MUI_INSTALLOPTIONS_SHOW

      Pop $R2
      Pop $R1
      Pop $R0

    FunctionEnd
If you need the InstallOptions return value (success, back, cancel, error), use the MUI_INSTALLOPTIONS_DISPLAY_RETURN or MUI_INSTALLOPTIONS_SHOW_RETURN macro. The return value will be added to the stack, so you can use the Pop command to get it. To read or write INI file values use these macro's:
    !insertmacro MUI_INSTALLOPTIONS_READ $VAR "ioFile.ini" "Field #" "Value Name"
    !insertmacro MUI_INSTALLOPTIONS_WRITE "ioFile.ini" "Field #" "Value Name" "Value"
For example, you can use the MUI_INSTALLOPTIONS_READ macro in a section to get the user input:
    !insertmacro MUI_INSTALLOPTIONS_READ $R0 "ioFile.ini" "Field 1" "State"
For more details about InstallOptions, validation of user input etc., check the InstallOptions documentation. Reserve files If you are using BZIP2 compression, it's important that files which are being extracted in the .onInit function or in Page functions are first in the data block, because this will make your installer start faster. If these functions are not above any other File command, insert the ReserveFile commands or macro's above other File commands:
    ReserveFile "ioFile.ini" ;Your own InstallOptions INI files

    !insertmacro MUI_RESERVEFILE_WELCOMEFINISHPAGE ;Welcome- or Finish page
    !insertmacro MUI_RESERVEFILE_INSTALLOPTION ;InstallOptions
    !insertmacro MUI_RESERVEFILE_LANGDLL ;LangDLL (language selection dialog)
Examples Basic: Basic.nsi Welcome/Finish page: WelcomeFinish.nsi Multilanguage: MultiLanguage.nsi Header bitmap: HeaderBitmap.nsi Custom pages: InstallOptions.nsi Start Menu Folder selection: StartMenu.nsi Customize the dialogs To change elements on the dialogs, modify the resource files Contrib\UIs directory using a resource editor such as Resource Hacker and use the interface setting to define to filename use your customized UI. The 'Please wait while Setup is loading...' text on the splash screen which is being displayed when the installer is starting (Verifying installer, Unpacking data) cannot be changed by the script, because the installer is not started yet when this dialog is being displayed. If you want to change this text, modify dialog 111 of modern.exe. The 'Verifying installer' and 'Unpacking data' texts are defined in the language header file of the NSIS exehead (Source\exehead\lang.h). To change them, you need to edit this file and recompile NSIS. To modify the Welcome and Finish dialog, edit the Install Options INI File ioSpecial.ini in the 'Contrib\Modern UI' directory. Customize Modern UI Functions If you want add your own code to functions inserted by the Modern UI, such as the .onGUIInit function and the Page functions, create your own function and let the Modern UI functions call them. Use the defines to define the name of your functions. Add the defines before the MUI_LANGUAGE macro's. Example:
    !define MUI_CUSTOMFUNCTION_GUIINIT myGuiInit

    Function myGUIInit
      ...your own code...
    FunctionEnd
GUI Init MUI_CUSTOMFUNCTION_GUIINIT MUI_CUSTOMFUNCTION_UNGUIINIT Welcome Page MUI_CUSTOMFUNCTION_WELCOME_PRE - You can write to the IO INI file of the page (ioSpecial.ini) MUI_CUSTOMFUNCTION_WELCOME_SHOW - ${MUI_HWND} contains HWND of Welcome dialog License Page MUI_CUSTOMFUNCTION_LICENSE_PRE MUI_CUSTOMFUNCTION_LICENSE_SHOW MUI_CUSTOMFUNCTION_LICENSE_LEAVE Components Page MUI_CUSTOMFUNCTION_COMPONENTS_PRE MUI_CUSTOMFUNCTION_COMPONENTS_SHOW MUI_CUSTOMFUNCTION_COMPONENTS_LEAVE Directory Page MUI_CUSTOMFUNCTION_DIRECTORY_PRE MUI_CUSTOMFUNCTION_DIRECTORY_SHOW MUI_CUSTOMFUNCTION_DIRECTORY_LEAVE Start Menu Folder Page MUI_CUSTOMFUNCTION_STARTMENU_PRE MUI_CUSTOMFUNCTION_STARTMENU_LEAVE Install Files Page MUI_CUSTOMFUNCTION_INSTFILES_PRE MUI_CUSTOMFUNCTION_INSTFILES_SHOW MUI_CUSTOMFUNCTION_INSTFILES_LEAVE Finish Page MUI_CUSTOMFUNCTION_FINISH_PRE - You can write to the IO INI file of the page (ioSpecial.ini) MUI_CUSTOMFUNCTION_FINISH_SHOW - ${MUI_HWND} contains HWND of Finish dialog Installer Abort MUI_CUSTOMFUNCTION_ABORT Uninstaller - Confirm Page MUI_UNCUSTOMFUNCTION_CONFIRM_PRE MUI_UNCUSTOMFUNCTION_CONFIRM_SHOW MUI_UNCUSTOMFUNCTION_CONFIRM_LEAVE Uninstaller - Uninstall Files Page MUI_UNCUSTOMFUNCTION_INSTFILES_PRE MUI_UNCUSTOMFUNCTION_INSTFILES_SHOW MUI_UNCUSTOMFUNCTION_INSTFILES_LEAVE Version history 1.65 - May 25, 2003 New page configuration system, no different system for installers with custom pages Default windows color for the license text background New format for example scripts 1.64 - April 27, 2003 Support for license page with checkbox or radiobuttons to let the user accept the agreement or not Macro's for finish headers don't have to be inserted anymore Language preference stored when installation has completed, no problems anymore when the users selects the wrong language Header text for aborted installation New macro's: get language for uninstaller, delete shortcuts Language specific fonts Welcome/Finish page INI files can be modified in pre functions More texts can be customized Language files have to be updated 1.63 - March 9, 2003 Support for a bitmap in the wizard header New defines to change the description area MUI_SYSTEM inserted automatically Single macro for language selection dialog Removed page description in window title Easier to customize resource files New system for custom functions Start Menu folder registry key automatically written New InstallOptions macro's that do not remove the return value from the stack Support for custom pages before the finish page Renamed Start Menu page defines 'Do not create shortcuts' checkbox can be removed 'MS Shell Dlg' font for header title RTL support Documentation updates Minor fixes Complete version history Credits Made by Joost Verburg. Icons designed by Nikos Adamamas, aka adni18. Thanks to Amir Szekely, aka KiCHiK, for his work on NSIS to make this possible. Help Please post questions at the NSIS Forum. License
    Copyright © 2002-2003 Joost Verburg

    This software is provided 'as-is', without any express or implied
    warranty. In no event will the authors be held liable for any damages
    arising from the use of this software.

    Permission is granted to anyone to use this software for any purpose,
    including commercial applications, and to alter it and redistribute
    it freely, subject to the following restrictions:

    1. The origin of this software must not be misrepresented;
       you must not claim that you wrote the original software.
       If you use this software in a product, an acknowledgment in the
       product documentation would be appreciated but is not required.
    2. Altered versions must be plainly marked as such,
       and must not be misrepresented as being the original software.
    3. This notice may not be removed or altered from any distribution.