Skip to content

[feat] Add NSIS installer hook to redefine NSIS constants #15267

Description

@WillemJann

Describe the problem

Currently it is not possible to change NSIS constants that are defined in the install script installer.nsi.

The NSIS Modern UI has a lot of useful configuration options, therefore it makes sense to redefine/undefine them.

Example: we want to remove the two of the checkboxes on the finish page ("Run program" and "Create desktop shortcut")

Describe the solution you'd like

A NSIS hook to redefine constants defined in the install script installer.nsi. For example:

!macro NSIS_HOOK_PREFINISH
    !undef MUI_FINISHPAGE_RUN
    !undef MUI_FINISHPAGE_SHOWREADME
!macroend

The name of the hook is something to decide on and probably depends on the location in the install script. Some suggestions: NSIS_HOOK_PREINIT, NSIS_HOOK_POSTINIT, NSIS_HOOK_PREFINISH, ...

Alternatives considered

A workaround for our specific example is to do not check the checkboxes by default, by adding the following to the top of our hooks.nsh script:

!define MUI_FINISHPAGE_RUN_NOTCHECKED
!define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED

This works because these constants are not defined in installer.nsi. This will not work and give errors for constants that are defined in installer.nsi. And this not really solves our problem because we want to hide the checkboxes.

Another alternative is to copy the full installer.nsi script, configure it using tauri.bundle.windows.nsis.template and then make the modifications in the custom script. However, we want to keep using the Tauri NSIS installer template, because it is very powerful and we want to keep up with the latest changes and improvements.

Additional context

We have a Tauri app with multiple entry points, identified with application arguments to the main executable. We are using the existing hooks NSIS_HOOK_POSTINSTALL and NSIS_HOOK_POSTUNINSTALL to create (and remove) four shortcuts instead of the default (one) shortcut. Our application is designed to be started via the custom shortcuts (which have application arguments) and therefore want to hide the default 'Run program' option on the finish page. We also want to hide the 'Add desktop shortcut' option on the finish page because our custom hook already created the desktop shortcuts.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions