Skip to content

[feat] Overriding installation path for NSIS installation packages during silent instalation doesn't work #6928

@gribunin

Description

@gribunin

Describe the problem

Usually the installation package generated with NSIS allows to pass the installation directory via command line. This is especially important for silent installations. The command line looks like this:

installer.exe /S /D=C:\Users\Public\installDir

In order the installer to support this parameter the code in the installer must look something like this:

${If} $InstDir == "" ; /D not used
    ; custom logic to set installation path
${EndIf}

NSIS template in the Tauri codebase (\tooling\bundler\src\bundle\windows\templates\installer.nsi ) doesn't check against if the $InstDir is already set (via command line) and just sets the $InstDir value based on install mode.

Describe the solution you'd like

I think the NSIS installation template must be modified so that the $InstDir will be set only if it wasn't set via command line parameter. Something like this:

${If} $InstDir == "" ; /D not used
  !if "${INSTALLMODE}" == "perMachine"
    ; Set default install location
    ${If} ${RunningX64}
      !if "${ARCH}" == "x64"
        StrCpy $INSTDIR "$PROGRAMFILES64\${PRODUCTNAME}"
      !else if "${ARCH}" == "arm64"
        StrCpy $INSTDIR "$PROGRAMFILES64\${PRODUCTNAME}"
      !else
        StrCpy $INSTDIR "$PROGRAMFILES\${PRODUCTNAME}"
      !endif
    ${Else}
      StrCpy $INSTDIR "$PROGRAMFILES\${PRODUCTNAME}"
    ${EndIf}
  !else if "${INSTALLMODE}" == "currentUser"
    StrCpy $INSTDIR "$LOCALAPPDATA\${PRODUCTNAME}"
  !endif
!endif

Alternatives considered

No response

Additional context

No response

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