Search code examples
windowselectronnsiselectron-builder

Electron Builder NSIS Create a shortcut in startup


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?


Solution

  • 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