NSIS Installer - Displaying different licences
Asked Answered
R

2

6

I'm trying to modify an existing NSIS install script to allow for different licence files to be presented to the user depending on whether they are a new or existing user. I have pre-existing code which detects an existing install in the .onInit section.

However I'm running into bumps trying to use the NSIS provided licence screen e.g.

!InsertMacro MUI_PAGE_LICENSE Content\Licence.rtf

I would like to be able to choose between Licence and Licence2.rtf (though they'll be renamed something representative in the final version).

I've tried using selectable sections calling functions which nest the !insertmacro but that doesn't work because it needs to be in the base level of the script.

I can't change the parameter to be runtime definable because it needs to know what the file is at compile time to build it into the installer.

I know I can roll my own custom page called from a function and do it that way but I was wondering if anyone had got the NSIS installer working with using the MUI_PAGE_LICENSE and different licences.

Thanks

Ruthie answered 12/3, 2010 at 16:57 Comment(0)
C
7

There are two ways to skin this cat:

  • Use 2 license pages and skip one of them
  • Load the license file manually at run-time

Two pages:

!define MUI_PAGE_CUSTOMFUNCTION_PRE skip1
!InsertMacro MUI_PAGE_LICENSE Content\Licence.rtf
!define MUI_PAGE_CUSTOMFUNCTION_PRE skip2
!InsertMacro MUI_PAGE_LICENSE Content\Licence2.rtf
#You need two functions skip1 and skip2, they should call `abort` to skip based on some state you determine at run-time

Manual load:

There is a plugin that does this for you (Not sure if it supports RTF)

I wrote some code that does this using the system plugin, you can find that on the nsis forum. To use that code, you would include your license files with normal File commands and extract the one you want to $pluginsdir and load it in the license page's show callback function.

Crescin answered 12/3, 2010 at 23:10 Comment(0)
D
6

There is an easier way. I use this code:

!insertmacro MUI_PAGE_LICENSE $(MUILicense)

Also, you have to put in your code lines like this:

LicenseLangString MUILicense ${LANG_POLISH} "SomeDirectory\licencja_pl.txt"
LicenseLangString MUILicense ${LANG_ENGLISH} "SomeDirectory\license_en.txt"

They don't have to appear before inserting license macro. In my code I defined them just below and it works fine.

Donny answered 7/3, 2012 at 21:22 Comment(1)
Thanks, this was exactly what I was searching for, all other docs/answers telling this with one of the following errors: missing $() around MUILicense var on your first script line, using static filename instead of var at the same line, using LANG_XY instead of ${LANG_XY} etc.Allomerism

© 2022 - 2024 — McMap. All rights reserved.