diff --git a/packages/electron-builder/src/targets/nsis.ts b/packages/electron-builder/src/targets/nsis.ts index 10b95bd996b..3e846cdf446 100644 --- a/packages/electron-builder/src/targets/nsis.ts +++ b/packages/electron-builder/src/targets/nsis.ts @@ -282,7 +282,7 @@ export default class NsisTarget extends Target { defines.allowToChangeInstallationDirectory = null } - if (options.menuCategory != null) { + if (options.menuCategory != null && options.menuCategory !== false) { const menu = sanitizeFileName(options.menuCategory === true ? packager.appInfo.companyName : options.menuCategory) if (!isEmptyOrSpaces(menu)) { defines.MENU_FILENAME = menu diff --git a/packages/electron-builder/templates/nsis/boringInstaller.nsh b/packages/electron-builder/templates/nsis/boringInstaller.nsh index 7990dfd563f..28b8f90fbc9 100644 --- a/packages/electron-builder/templates/nsis/boringInstaller.nsh +++ b/packages/electron-builder/templates/nsis/boringInstaller.nsh @@ -8,9 +8,9 @@ !ifndef BUILD_UNINSTALLER Function StartApp ${if} ${Updated} - ${StdUtils.ExecShellAsUser} $0 "$SMPROGRAMS\${PRODUCT_FILENAME}.lnk" "open" "--updated" + ${StdUtils.ExecShellAsUser} $0 "$startMenuLink" "open" "--updated" ${else} - ${StdUtils.ExecShellAsUser} $0 "$SMPROGRAMS\${PRODUCT_FILENAME}.lnk" "open" "" + ${StdUtils.ExecShellAsUser} $0 "$startMenuLink" "open" "" ${endif} FunctionEnd diff --git a/packages/electron-builder/templates/nsis/installSection.nsh b/packages/electron-builder/templates/nsis/installSection.nsh index 80420de75b0..b692aef5dfb 100644 --- a/packages/electron-builder/templates/nsis/installSection.nsh +++ b/packages/electron-builder/templates/nsis/installSection.nsh @@ -184,7 +184,7 @@ WinShell::SetLnkAUMI "$desktopLink" "${APP_ID}" ${IfNot} ${Silent} # otherwise app window will be in backround HideWindow - Call StartApp + !insertmacro StartApp ${EndIf} !endif !insertmacro quitSuccess diff --git a/packages/electron-builder/templates/nsis/installer.nsi b/packages/electron-builder/templates/nsis/installer.nsi index 578e62a7acb..df0d268e444 100644 --- a/packages/electron-builder/templates/nsis/installer.nsi +++ b/packages/electron-builder/templates/nsis/installer.nsi @@ -1,3 +1,6 @@ +Var startMenuLink +Var desktopLink + !include "common.nsh" !include "MUI2.nsh" !include "multiUser.nsh" @@ -23,9 +26,6 @@ !insertmacro customHeader !endif -Var startMenuLink -Var desktopLink - !ifdef BUILD_UNINSTALLER SilentInstall silent !else diff --git a/packages/electron-builder/templates/nsis/oneClick.nsh b/packages/electron-builder/templates/nsis/oneClick.nsh index 3b9ac68d087..b8ed735397d 100644 --- a/packages/electron-builder/templates/nsis/oneClick.nsh +++ b/packages/electron-builder/templates/nsis/oneClick.nsh @@ -1,17 +1,20 @@ !ifndef BUILD_UNINSTALLER !ifdef RUN_AFTER_FINISH !include StdUtils.nsh - Function StartApp + !macro StartApp + Var /GLOBAL startAppArgs + ${if} ${Updated} + StrCpy $startAppArgs "--updated" + ${else} + StrCpy $startAppArgs "" + ${endif} + !ifdef INSTALL_MODE_PER_ALL_USERS - ${StdUtils.ExecShellAsUser} $0 "$SMPROGRAMS\${PRODUCT_FILENAME}.lnk" "open" "" + ${StdUtils.ExecShellAsUser} $0 $startMenuLink "open" "$startAppArgs" !else - ${if} ${Updated} - ExecShell "" "$SMPROGRAMS\${PRODUCT_FILENAME}.lnk" "--updated" - ${else} - ExecShell "" "$SMPROGRAMS\${PRODUCT_FILENAME}.lnk" - ${endif} + ExecShell "" "$startMenuLink" "$startAppArgs" !endif - FunctionEnd + !macroend !endif !ifmacrodef licensePage diff --git a/test/src/windows/oneClickInstallerTest.ts b/test/src/windows/oneClickInstallerTest.ts index dfb1f07497f..26455c0a96d 100644 --- a/test/src/windows/oneClickInstallerTest.ts +++ b/test/src/windows/oneClickInstallerTest.ts @@ -119,7 +119,7 @@ test.ifAll("menuCategory", app({ }, config: { nsis: { - perMachine: true, + oneClick: false, menuCategory: true, artifactName: "${productName} CustomName ${version}.${ext}" },