summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2023-08-16 23:12:16 -0700
committerKaz Kylheku <kaz@kylheku.com>2023-08-16 23:49:18 -0700
commit927ce14064e931edcf9f55582fd6a4f4b7c0567c (patch)
tree06075ebd3f957a1b0e8fce2d3a4ca7afb17fd10e
parentf7ce2c45562e9a996c6a77a469f1036c80a6b780 (diff)
downloadtxr-927ce14064e931edcf9f55582fd6a4f4b7c0567c.tar.gz
txr-927ce14064e931edcf9f55582fd6a4f4b7c0567c.tar.bz2
txr-927ce14064e931edcf9f55582fd6a4f4b7c0567c.zip
windows: don't require admin privilege.
* inst.nsi (RequestExecutionLevel): Use the value "highest" instead of "admin", so that privilege is required for users that have it, otherwise not. (AccountType): New variable. (.onInit): Obtain the account type and store it in AccountType. Default the installation directory to $LOCALAPPDATA. If the user is admin, change the default to the appropriate Program Files directory. (TXR): If the user isn't admin, add TXR to the current user's PATH rather than the system PATH for everyone. (Uninstall): Remove TXR from the appropriate PATH.
-rw-r--r--inst.nsi25
1 files changed, 20 insertions, 5 deletions
diff --git a/inst.nsi b/inst.nsi
index ae3e4d07..262f2eb8 100644
--- a/inst.nsi
+++ b/inst.nsi
@@ -10,11 +10,18 @@ UninstallIcon "win\txr.ico"
SetCompressor lzma
CRCCheck on
-RequestExecutionLevel admin
+
+RequestExecutionLevel highest
+
+var AccountType
Function .onInit
- # default installation dir
- StrCpy $INSTDIR "C:\Program Files"
+ StrCpy $INSTDIR "$LOCALAPPDATA"
+ UserInfo::GetAccountType
+ Pop $AccountType
+ ${If} $AccountType == "Admin"
+ StrCpy $INSTDIR "$PROGRAMFILES32"
+ ${EndIf}
FunctionEnd
Function .onInstSuccess
@@ -71,7 +78,11 @@ section "TXR"
CreateShortCut "$SMPROGRAMS\txr\uninstall.lnk" "$INSTDIR\txr\uninstall.exe"
CreateShortCut "$SMPROGRAMS\txr\install-root.lnk" "$INSTDIR\txr"
CreateShortCut "$STARTMENU\txr.lnk" "$INSTDIR\txr\bin\txr.exe"
- ${EnvVarUpdate} $0 "PATH" "A" "HKLM" "$INSTDIR\txr\bin"
+ ${If} $AccountType == "Admin"
+ ${EnvVarUpdate} $0 "PATH" "A" "HKLM" "$INSTDIR\txr\bin"
+ ${Else}
+ ${EnvVarUpdate} $0 "PATH" "A" "HKCU" "$INSTDIR\txr\bin"
+ ${Endif}
${RegisterExtension} "$INSTDIR\txr\bin\txr-win.exe" ".txr" "TXR Pattern Language"
${RegisterExtension} "$INSTDIR\txr\bin\txr-win.exe" ".tl" "TXR Lisp"
${RegisterExtension} "$INSTDIR\txr\bin\txr-win.exe" ".tlo" "Compiled TXR Lisp"
@@ -82,7 +93,11 @@ section "Uninstall"
# $INSTDIR is now where the uninstaller is installed,
# not the $INSTDIR that was used during installation!
- ${un.EnvVarUpdate} $0 "PATH" "R" "HKLM" "$INSTDIR\bin"
+ ${If} $AccountType == "Admin"
+ ${un.EnvVarUpdate} $0 "PATH" "R" "HKLM" "$INSTDIR\bin"
+ ${Else}
+ ${un.EnvVarUpdate} $0 "PATH" "R" "HKCU" "$INSTDIR\bin"
+ ${Endif}
${UnregisterExtension} ".txr" "TXR Pattern Language"
${UnregisterExtension} ".tl" "TXR Lisp"
${UnregisterExtension} ".tlo" "Compiled TXR Lisp"