!include FileFunc.nsh!include UAC.nsh!define FOLDERID_UserProgramFiles {5CD7AEE2-2219-4A67-B85D-6C9CE15660CB}!define KF_FLAG_CREATE 0x00008000# allow user to define own custom!define /ifndef INSTALL_REGISTRY_KEY "Software\${APP_GUID}"!define /ifndef UNINSTALL_REGISTRY_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTALL_APP_KEY}"# current Install Mode ("all" or "CurrentUser")Var installMode!ifndef INSTALL_MODE_PER_ALL_USERS!ifndef ONE_CLICKVar hasPerUserInstallationVar hasPerMachineInstallation!endifVar PerUserInstallationFolder!macro setInstallModePerUserStrCpy $installMode CurrentUserSetShellVarContext current# Ρhecks registry for previous installation pathReadRegStr $perUserInstallationFolder HKCU "${INSTALL_REGISTRY_KEY}" InstallLocation${if} $perUserInstallationFolder != ""StrCpy $INSTDIR $perUserInstallationFolder${else}StrCpy $0 "$LocalAppData\Programs"System::Store S# Win7 has a per-user programfiles known folder and this can be a non-default locationSystem::Call 'SHELL32::SHGetKnownFolderPath(g "${FOLDERID_UserProgramFiles}", i ${KF_FLAG_CREATE}, p 0, *p .r2)i.r1'${If} $1 == 0System::Call '*$2(&w${NSIS_MAX_STRLEN} .s)'StrCpy $0 $1System::Call 'OLE32::CoTaskMemFree(p r2)'${endif}System::Store LStrCpy $INSTDIR "$0\${APP_FILENAME}"${endif}# allow /D switch to override installation path https://github.com/electron-userland/electron-builder/issues/1551${StdUtils.GetParameter} $R0 "D" ""${If} $R0 != ""StrCpy $INSTDIR $R0${endif}!macroend!endif!ifdef INSTALL_MODE_PER_ALL_USERS_REQUIREDVar perMachineInstallationFolder!macro setInstallModePerAllUsersStrCpy $installMode allSetShellVarContext all!ifdef BUILD_UNINSTALLER${IfNot} ${UAC_IsAdmin}ShowWindow $HWNDPARENT ${SW_HIDE}!insertmacro UAC_RunElevatedQuit${endif}!endif# Ρheck registry for previous installation pathReadRegStr $perMachineInstallationFolder HKLM "${INSTALL_REGISTRY_KEY}" InstallLocation${if} $perMachineInstallationFolder != ""StrCpy $INSTDIR $perMachineInstallationFolder${else}StrCpy $0 "$PROGRAMFILES"!ifdef APP_64${if} ${RunningX64}StrCpy $0 "$PROGRAMFILES64"${endif}!endif!ifdef MENU_FILENAMEStrCpy $0 "$0\${MENU_FILENAME}"!endifStrCpy $INSTDIR "$0\${APP_FILENAME}"${endif}# allow /D switch to override installation path https://github.com/electron-userland/electron-builder/issues/1551${StdUtils.GetParameter} $R0 "D" ""${If} $R0 != ""StrCpy $INSTDIR $R0${endif}!macroend!endif