Custom Finish Page

From NSIS Wiki
Jump to navigationJump to search

Creating custom finish page displaying components installed

You will need to add code to your nsi script and there is INI files to be created too. The basic theory is, you have a variable for each component. When you install each component, you set its variable, then when it comes to the finish page, depending on the combination of variables set, it will display the appropriate finish page.

NSIS Script

You need to include LogicLib to use ${If} ${Else} etc..

   !include "LogicLib.nsh"

When setting the pages in the order you want, replace the default finish page with

   # Custom finish page to show what was installed
   Page custom finishfull

You need to set variables for each component, in this case i have 3, the .net compact framework, my app, and the map used by the app

   Var netcf
   Var app
   Var map

When you are installing the component, write the value "installed" (can be anything) to the components variable.

   # Process installing netcf component
   StrCpy "netcf" "installed"
   # Process installing app
   StrCpy "app" "installed"
   # Process installing map
   StrCpy "map" "installed"

This is the function that the custom finish page calls

 Function finishfull
   ${If} $netcf == ""
         ${AndIf} $app == ""
             ${AndIf} $map == ""
 # show page nothing installed
         !insertmacro MUI_HEADER_TEXT "$(FINISHFULL_TITLE)" "$(FINISHFULL_SUBTITLE)"
         # Display the page.
         !insertmacro MUI_INSTALLOPTIONS_DISPLAY "finishfull_none"
   ${ElseIf} $app == "installed"
         ${AndIf} $netcf == ""
             ${AndIf} $map == ""
 # show page App installed
         !insertmacro MUI_HEADER_TEXT "$(FINISHFULL_TITLE)" "$(FINISHFULL_SUBTITLE)"
         # Display the page.
         !insertmacro MUI_INSTALLOPTIONS_DISPLAY "finishfull_app"
   ${ElseIf} $map == "installed"
         ${AndIf} $netcf == ""
             ${AndIf} $app == ""
 # show page Map database installed
         !insertmacro MUI_HEADER_TEXT "$(FINISHFULL_TITLE)" "$(FINISHFULL_SUBTITLE)"
         # Display the page.
         !insertmacro MUI_INSTALLOPTIONS_DISPLAY "finishfull_map"
   ${ElseIf} $app == "installed"
         ${AndIf} $map == "installed"
             ${AndIf} $netcf == ""
 # show page App and Map installed
         !insertmacro MUI_HEADER_TEXT "$(FINISHFULL_TITLE)" "$(FINISHFULL_SUBTITLE)"
         # Display the page.
         !insertmacro MUI_INSTALLOPTIONS_DISPLAY "finishfull_appmap"
   ${ElseIf} $netcf == "installed"
         ${AndIf} $app == ""
             ${AndIf} $map == ""
 # show page NetCF installed
         !insertmacro MUI_HEADER_TEXT "$(FINISHFULL_TITLE)" "$(FINISHFULL_SUBTITLE)"
         # Display the page.
         !insertmacro MUI_INSTALLOPTIONS_DISPLAY "finishfull_netcf"
   ${ElseIf} $app == "installed"
         ${AndIf} $netcf == "installed"
             ${AndIf} $map == ""
 # show page App and NetCF installed
         !insertmacro MUI_HEADER_TEXT "$(FINISHFULL_TITLE)" "$(FINISHFULL_SUBTITLE)"
         # Display the page.
         !insertmacro MUI_INSTALLOPTIONS_DISPLAY "finishfull_netcfapp"
   ${ElseIf} $map == "installed"
         ${AndIf} $netcf == "installed"
             ${AndIf} $app == ""
 # show page Map and NetCF installed
         !insertmacro MUI_HEADER_TEXT "$(FINISHFULL_TITLE)" "$(FINISHFULL_SUBTITLE)"
         # Display the page.
         !insertmacro MUI_INSTALLOPTIONS_DISPLAY "finishfull_netcfmap"
   ${ElseIf} $app == "installed"
         ${AndIf} $map == "installed"
             ${AndIf} $netcf == "installed"
 # show page NetCF, App and Map database installed
         !insertmacro MUI_HEADER_TEXT "$(FINISHFULL_TITLE)" "$(FINISHFULL_SUBTITLE)"
         # Display the page.
         !insertmacro MUI_INSTALLOPTIONS_DISPLAY "finishfull_all"
   ${EndIf}
 FunctionEnd

These are the ini files for the different combinations of components that can be installed they need to be extracted on the installers initialization

 Function .onInit
    !insertmacro MUI_INSTALLOPTIONS_EXTRACT_AS "assets\finishfull_none.ini" "finishfull_none"
    !insertmacro MUI_INSTALLOPTIONS_EXTRACT_AS "assets\finishfull_appmap.ini" "finishfull_appmap"
    !insertmacro MUI_INSTALLOPTIONS_EXTRACT_AS "assets\finishfull_app.ini" "finishfull_app"
    !insertmacro MUI_INSTALLOPTIONS_EXTRACT_AS "assets\finishfull_netcfapp.ini" "finishfull_netcfapp"
    !insertmacro MUI_INSTALLOPTIONS_EXTRACT_AS "assets\finishfull_netcfmap.ini" "finishfull_netcfmap"
    !insertmacro MUI_INSTALLOPTIONS_EXTRACT_AS "assets\finishfull_netcf.ini" "finishfull_netcf"
    !insertmacro MUI_INSTALLOPTIONS_EXTRACT_AS "assets\finishfull_map.ini" "finishfull_map"
    !insertmacro MUI_INSTALLOPTIONS_EXTRACT_AS "assets\finishfull_all.ini" "finishfull_all"
 FunctionEnd

INI file structure

I strongly recommend using HM NIS Edit to create these files. It is very difficult to get an idea of what it will look like when just writing text, but here's the format HM NIS Edit creates This example has 2 text boxes, its easy enough to make out what each of the settings are. This is the finishfull_all.ini file. For the different components, change the contents of field 2 and then save them as the appropriate filename.

; Ini file generated by the HM NIS Edit IO designer.
[Settings]
NumFields=2

[Field 1]
Type=Label
Text=Completing the Setup Wizard
Left=0
Right=-1
Top=6
Bottom=17

[Field 2]
Type=Label
Text=The following components were installed:\r\n\r\n - Microsoft .NET Compact Framework 2.0\r\n\r\n - Application\r\n\r\n - Map
Left=0
Right=-1
Top=38
Bottom=147