Custom Finish Page: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
 
(4 intermediate revisions by the same user not shown)
Line 7: Line 7:


You need to include LogicLib to use ${If} ${Else} etc..  
You need to include LogicLib to use ${If} ${Else} etc..  
 
<highlight-nsis>
   !include "LogicLib.nsh"
   !include "LogicLib.nsh"
 
</highlight-nsis>


When setting the pages in the order you want, replace the default finish page with
When setting the pages in the order you want, replace the default finish page with
 
<highlight-nsis>
   # Custom finish page to show what was installed
   # Custom finish page to show what was installed
   Page custom finishfull
   Page custom finishfull
 
</highlight-nsis>


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
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
<highlight-nsis>
   Var netcf
   Var netcf
   Var app
   Var app
   Var map
   Var map
 
</highlight-nsis>


When you are installing the component, write the value "installed" (can be anything) to the components variable.
When you are installing the component, write the value "installed" (can be anything) to the components variable.
 
<highlight-nsis>
   # Process installing netcf component
   # Process installing netcf component
   StrCpy "netcf" "installed"
   StrCpy "netcf" "installed"
 
</highlight-nsis>
<highlight-nsis>
   # Process installing app
   # Process installing app
   StrCpy "app" "installed"
   StrCpy "app" "installed"
 
</highlight-nsis>
<highlight-nsis>
   # Process installing map
   # Process installing map
   StrCpy "map" "installed"
   StrCpy "map" "installed"
 
</highlight-nsis>
This is the function that the custom finish page calls
This is the function that the custom finish page calls
 
<highlight-nsis>
  Function finishfull
  Function finishfull
   ${If} $netcf == ""
   ${If} $netcf == ""
Line 95: Line 98:
   ${EndIf}
   ${EndIf}
  FunctionEnd
  FunctionEnd
 
</highlight-nsis>


These are the ini files for the different combinations of components that can be installed
These are the ini files for the different combinations of components that can be installed
they need to be extracted on the installers initialization
they need to be extracted on the installers initialization
 
<highlight-nsis>
  Function .onInit
  Function .onInit
     !insertmacro MUI_INSTALLOPTIONS_EXTRACT_AS "assets\finishfull_none.ini" "finishfull_none"
     !insertmacro MUI_INSTALLOPTIONS_EXTRACT_AS "assets\finishfull_none.ini" "finishfull_none"
Line 110: Line 113:
     !insertmacro MUI_INSTALLOPTIONS_EXTRACT_AS "assets\finishfull_all.ini" "finishfull_all"
     !insertmacro MUI_INSTALLOPTIONS_EXTRACT_AS "assets\finishfull_all.ini" "finishfull_all"
  FunctionEnd
  FunctionEnd
 
</highlight-nsis>


== INI file structure ==
== INI file structure ==


I strongly recommend using [http://hmne.sourceforge.net/ 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
I strongly recommend using [http://hmne.sourceforge.net/ 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 [http://hmne.sourceforge.net/ HM NIS Edit] creates
This example has 2 text boxes, its easy enough to make out what each of the settings are.
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.
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 [http://hmne.sourceforge.net/ HM NIS Edit] IO designer.
  ; Ini file generated by the HM NIS Edit IO designer.
  [Settings]
  [Settings]
  NumFields=2
  NumFields=2

Latest revision as of 00:25, 15 November 2006

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