[prev in list] [next in list] [prev in thread] [next in thread] 

List:       nsis-commits
Subject:    [NSIS-commits] SF.net SVN: nsis:[7155] NSIS/trunk
From:       anders_k--- via NSIS-commits <nsis-commits () lists ! sourceforge ! net>
Date:       2020-03-17 19:02:43
Message-ID: 1584471763.311051.31257 () sfp-scm-7 ! v30 ! lw ! sourceforge ! com
[Download RAW message or body]

Revision: 7155
          http://sourceforge.net/p/nsis/code/7155
Author:   anders_k
Date:     2020-03-17 19:02:42 +0000 (Tue, 17 Mar 2020)
Log Message:
-----------
Added install-per-user.nsi example

Modified Paths:
--------------
    NSIS/trunk/Docs/src/generalpurpose.but
    NSIS/trunk/Examples/SConscript
    NSIS/trunk/Examples/makensis.nsi

Added Paths:
-----------
    NSIS/trunk/Examples/install-per-user.nsi

Modified: NSIS/trunk/Docs/src/generalpurpose.but
===================================================================
--- NSIS/trunk/Docs/src/generalpurpose.but	2020-03-12 23:43:51 UTC (rev 7154)
+++ NSIS/trunk/Docs/src/generalpurpose.but	2020-03-17 19:02:42 UTC (rev 7155)
@@ -88,9 +88,16 @@
 Get the path of a \W{https://docs.microsoft.com/en-us/windows/win32/shell/knownfolderid}{known \
folder}. The error flag is set and the output variable is empty if the call fails or \
the knownfolderid guid is not available. This function is only able to resolve known \
folders Windows Vista or higher.  
 \c !include WinCore.nsh
-\c GetKnownFolderPath $InstDir ${FOLDERID_UserProgramFiles}
-\c StrCmp $InstDir "" 0 +2 
-\c StrCpy $InstDir "$LocalAppData\Programs"
+\c !include LogicLib.nsh
+\c 
+\c Function .onInit
+\c ${If} $InstDir == ""
+\c   GetKnownFolderPath $InstDir ${FOLDERID_UserProgramFiles} ; This exists on Win7+
+\c   StrCmp $InstDir "" 0 +2 
+\c   StrCpy $InstDir "$LocalAppData\Programs" ; Fallback directory
+\c   StrCpy $InstDir "$InstDir\$(^Name)"
+\c ${EndIf}
+\c FunctionEnd
 
 \S2{getfullpathname} GetFullPathName
 

Modified: NSIS/trunk/Examples/SConscript
===================================================================
--- NSIS/trunk/Examples/SConscript	2020-03-12 23:43:51 UTC (rev 7154)
+++ NSIS/trunk/Examples/SConscript	2020-03-17 19:02:42 UTC (rev 7155)
@@ -6,6 +6,7 @@
 	FileFunc.nsi
 	FileFuncTest.nsi
 	gfx.nsi
+	install-per-user.nsi
 	languages.nsi
 	Library.nsi
 	LogicLib.nsi

Added: NSIS/trunk/Examples/install-per-user.nsi
===================================================================
--- NSIS/trunk/Examples/install-per-user.nsi	                        (rev 0)
+++ NSIS/trunk/Examples/install-per-user.nsi	2020-03-17 19:02:42 UTC (rev 7155)
@@ -0,0 +1,78 @@
+/*
+
+This example script installs a simple application for a single user.
+
+If multiple users on the same machine run this installer, each user
+will end up with a separate install that is not affected by
+update/removal operations performed by other users.
+
+Per-user installers should only write to HKCU and 
+folders inside the users profile.
+
+*/
+
+!define NAME "Per-User example"
+!define REGPATH_UNINSTSUBKEY \
"Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}" +Name "${NAME}"
+OutFile "${NAME}.exe"
+Unicode True
+RequestExecutionLevel User ; We don't need UAC elevation
+InstallDir "" ; Don't set a default $InstDir so we can detect /D= and \
InstallDirRegKey +InstallDirRegKey HKCU "${REGPATH_UNINSTSUBKEY}" "UninstallString"
+
+!include LogicLib.nsh
+!include WinCore.nsh
+
+
+Page Directory
+Page InstFiles
+
+Uninstpage UninstConfirm
+Uninstpage InstFiles
+
+
+Function .onInit
+  SetShellVarContext Current
+
+  ${If} $InstDir == "" ; No /D= nor InstallDirRegKey?
+    GetKnownFolderPath $InstDir ${FOLDERID_UserProgramFiles} ; This folder only \
exists on Win7+ +    StrCmp $InstDir "" 0 +2 
+    StrCpy $InstDir "$LocalAppData\Programs" ; Fallback directory
+
+    StrCpy $InstDir "$InstDir\$(^Name)"
+  ${EndIf}
+FunctionEnd
+
+
+Section "Program files (Required)"
+  SectionIn Ro
+
+  SetOutPath $InstDir
+  WriteUninstaller "$InstDir\Uninst.exe"
+  WriteRegStr HKCU "${REGPATH_UNINSTSUBKEY}" "DisplayName" "${NAME}"
+  WriteRegStr HKCU "${REGPATH_UNINSTSUBKEY}" "UninstallString" \
'"$InstDir\Uninst.exe"' +  WriteRegDWORD HKCU "${REGPATH_UNINSTSUBKEY}" "NoModify" 1
+  WriteRegDWORD HKCU "${REGPATH_UNINSTSUBKEY}" "NoRepair" 1
+
+  File "/oname=$InstDir\MyApp.exe" "${NSISDIR}\Bin\MakeLangId.exe" ; Pretend that we \
have a real application to install +
+  ;WriteRegStr HKCU "Software\Classes\.myfileext" "myfiletype"
+  ;WriteRegStr HKCU "Software\Classes\myfiletype\shell\myapp\command" "" \
'"$InstDir\MyApp.exe" "%1"' +SectionEnd
+
+Section "Start Menu shortcut"
+  CreateShortcut /NoWorkingDir "$SMPrograms\${NAME}.lnk" "$InstDir\MyApp.exe"
+SectionEnd
+
+
+Section -Uninstall
+  Delete "$InstDir\MyApp.exe"
+  Delete "$InstDir\Uninst.exe"
+  RMDir "$InstDir"
+  DeleteRegKey HKCU "${REGPATH_UNINSTSUBKEY}"
+  ;DeleteRegKey HKCU "Software\Classes\myfiletype\shell\myapp"
+  ;DeleteRegKey /IfEmpty HKCU "Software\Classes\myfiletype\shell"
+  ;DeleteRegKey /IfEmpty HKCU "Software\Classes\myfiletype"
+
+  Delete "$SMPrograms\${NAME}.lnk"
+SectionEnd

Modified: NSIS/trunk/Examples/makensis.nsi
===================================================================
--- NSIS/trunk/Examples/makensis.nsi	2020-03-12 23:43:51 UTC (rev 7154)
+++ NSIS/trunk/Examples/makensis.nsi	2020-03-17 19:02:42 UTC (rev 7155)
@@ -311,6 +311,7 @@
   File ..\Examples\makensis.nsi
   File ..\Examples\example1.nsi
   File ..\Examples\example2.nsi
+  File ..\Examples\install-per-user.nsi
   File ..\Examples\viewhtml.nsi
   File ..\Examples\waplugin.nsi
   File ..\Examples\bigtest.nsi

This was sent by the SourceForge.net collaborative development platform, the world's \
largest Open Source development site.



_______________________________________________
NSIS-commits mailing list
NSIS-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nsis-commits


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic