Skip to content

NSIS - Change $INSTDIR to a custom path #1961

Description

@hemavidal

Electron Builder - 19.22.1
Target - NSIS

I'm trying to change the default installation directory to custom(Ex: C:\MyApp) and remove default(C:\Program Files\MyApp).
package.json

{
    "win": {
      "target": "NSIS",
      "icon": "build/icon.ico"
    },
    "nsis": {
      "oneClick": false,
      "allowElevation": true,
      "allowToChangeInstallationDirectory": true,
      "createDesktopShortcut": true,
      "include": "build/installer.nsh"
    }
}

I used !macro preInit, but didn't work:
build/installer.nsh

!macro preInit
  StrCpy $INSTDIR "C:\MyApp"
!macroend

error

command StrCpy not valid outside Section or Function

It is possible to change default installation do C:\MyApp even if installer have only in elevation mode?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions