9

I would like to change the install directory on Windows, my Electron App is built with electron-builder.

I've tried putting a installer.nsh file inside the build folder, but it's still the same, it always installs under the default path AppData/Roaming/.

This is my installer.nsh:

!macro preInit
 SetRegView 64
  WriteRegExpandStr HKLM "${INSTALL_REGISTRY_KEY}" InstallLocation "C:\CustomPath"
  WriteRegExpandStr HKCU "${INSTALL_REGISTRY_KEY}" InstallLocation "C:\CustomPath"
 SetRegView 32
  WriteRegExpandStr HKLM "${INSTALL_REGISTRY_KEY}" InstallLocation "C:\CustomPath"
  WriteRegExpandStr HKCU "${INSTALL_REGISTRY_KEY}" InstallLocation "C:\CustomPath"
!macroend

Has anyone managed to change the default install directory with electron-builder?

Thank you!

Joshua
  • 5,032
  • 2
  • 29
  • 45
s-leg3ndz
  • 3,260
  • 10
  • 32
  • 60

1 Answers1

9

For anyone still looking for an answer to this question. Putting the installer.nsh inside the build folder is the first part. The second part, you need to tell the installer to look for it. Under nsis see the last line: "include": "build/installer.nsh"

  ...
  "nsis": {
    "allowToChangeInstallationDirectory": true,
    "oneClick": false,
    "license": "license.html",
    "include": "build/installer.nsh"
  },
  ...

That did the trick for me.

oyalhi
  • 3,834
  • 4
  • 40
  • 45