Electron Builder NSIS Create a shortcut in startup
Asked Answered
S

2

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?

Stereochemistry answered 24/1, 2018 at 12:46 Comment(0)
S
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
Stereochemistry answered 25/1, 2018 at 8:51 Comment(0)
A
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

Anatto answered 24/1, 2018 at 16:3 Comment(2)
I want to create a shortcut at the startup in start menuStereochemistry
This does not answer the questionLeandraleandre

© 2022 - 2024 — McMap. All rights reserved.