Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

electron-builder change install directory on Windows

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!

like image 692
s-leg3ndz Avatar asked Apr 17 '18 09:04

s-leg3ndz


1 Answers

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.

like image 83
oyalhi Avatar answered Oct 02 '22 08:10

oyalhi