3

I am using Electron Builder to generate an NSIS installer for windows. I need the installer to create a shortcut in the startup menu.

How can I do that?

This is Electron Builder documentation about NSIS Scripts. https://www.electron.build/configuration/nsis#custom-nsis-script

Where should I put code to be executed after installing the application?

2 Answers 2

9

I was able to do this by putting the code that creates the shortcut in side the customInstall macro in a custom instllaer script for NSIS

In package.json

"build": {
  "nsis": {
      "include": "build/installer.nsh",
  },

This is to be able to use a custom script.

And in the build/installer.nsh

!macro customInstall
      CreateShortCut "$SMSTARTUP\filename.lnk" "$INSTDIR\filename.exe"
!macroend
3

Use the "createStartMenuShortcut" option in the top-level nsis key in your electron-builder config:

"build": {
  "nsis": {
    "createStartMenuShortcut": true,
  },
  //Rest of the config
}

You can find more config options in the docs

2
  • 2
    I want to create a shortcut at the startup in start menu Commented Jan 25, 2018 at 8:36
  • 1
    This does not answer the question
    – Yigal
    Commented Nov 24, 2019 at 10:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.