Skip to content

Commit

Permalink
Merge pull request #1324 from eht16/issue1321_fix_windows_user_instal…
Browse files Browse the repository at this point in the history
…lation

Windows installer: Prefer Geany installation directory over user's HOME
  • Loading branch information
eht16 authored Jun 23, 2024
2 parents f1b1bbf + 9c2ea2c commit 739a801
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions build/geany-plugins.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ ManifestSupportedOS all

OutFile "${GEANY_PLUGINS_INSTALLER_NAME}"

Var Answer
Var UserIsAdmin
Var UserName
Var GEANY_INSTDIR
Var UNINSTDIR
Expand Down Expand Up @@ -156,7 +156,7 @@ Section -Post

WriteUninstaller "$INSTDIR\uninst-plugins.exe"
WriteRegStr SHCTX "${PRODUCT_DIR_REGKEY}" Path "$INSTDIR"
${if} $Answer == "yes" ; if user is admin
${if} $UserIsAdmin == "yes"
WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst-plugins.exe"
WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\bin\Geany.exe"
Expand Down Expand Up @@ -378,16 +378,13 @@ FunctionEnd
Function .onInit
; (from http://jabref.svn.sourceforge.net/viewvc/jabref/trunk/jabref/src/windows/nsis/setup.nsi)
; If the user does *not* have administrator privileges, abort
StrCpy $Answer ""
StrCpy $UserIsAdmin ""
StrCpy $UserName ""
!insertmacro IsUserAdmin $Answer $UserName ; macro from LyXUtils.nsh
${if} $Answer == "yes"
!insertmacro IsUserAdmin $UserIsAdmin $UserName ; macro from LyXUtils.nsh
${if} $UserIsAdmin == "yes"
SetShellVarContext all ; set that e.g. shortcuts will be created for all users
${else}
SetShellVarContext current
; TODO is this really what we want? $PROGRAMFILES is not much better because
; probably the unprivileged user can't write it anyways
StrCpy $INSTDIR "$PROFILE\$(^Name)"
${endif}

; prevent running multiple instances of the installer
Expand All @@ -403,6 +400,12 @@ Function .onInit
StrCpy $INSTDIR "$GEANY_INSTDIR"
${EndIf}

; if $INSTDIR has not been set yet above, set it to the profile directory for non-admin users
${If} $INSTDIR == ""
${AndIf} $UserIsAdmin != "yes"
StrCpy $INSTDIR "$PROFILE\$(^Name)"
${EndIf}

; warn about a new install over an existing installation
ReadRegStr $R0 SHCTX "${PRODUCT_UNINST_KEY}" "UninstallString"
StrCmp $R0 "" finish
Expand Down Expand Up @@ -433,9 +436,9 @@ FunctionEnd

Function un.onInit
; If the user does *not* have administrator privileges, abort
StrCpy $Answer ""
!insertmacro IsUserAdmin $Answer $UserName
${if} $Answer == "yes"
StrCpy $UserIsAdmin ""
!insertmacro IsUserAdmin $UserIsAdmin $UserName
${if} $UserIsAdmin == "yes"
SetShellVarContext all
${else}
; check if the Geany has been installed with admin permisions
Expand Down

0 comments on commit 739a801

Please sign in to comment.