Added the install-shared.nsi example
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@7158 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
657a66f071
commit
02eb8e338a
5 changed files with 91 additions and 5 deletions
|
@ -141,7 +141,7 @@ This constant is not available on Windows 95 unless Internet Explorer 4 is insta
|
|||
|
||||
The user's music files directory. The context of this constant (All Users or Current user) depends on the \R{setshellvarcontext}{SetShellVarContext} setting. The default is the current user.
|
||||
|
||||
This constant is available on Windows XP, ME and above.
|
||||
This constant is available on Windows ME, XP and above.
|
||||
|
||||
\e{$PICTURES}
|
||||
|
||||
|
@ -153,7 +153,7 @@ This constant is available on Windows 2000, XP, ME and above.
|
|||
|
||||
The user's video files directory. The context of this constant (All Users or Current user) depends on the \R{setshellvarcontext}{SetShellVarContext} setting. The default is the current user.
|
||||
|
||||
This constant is available on Windows XP, ME and above.
|
||||
This constant is available on Windows ME, XP and above.
|
||||
|
||||
\e{$NETHOOD}
|
||||
|
||||
|
@ -171,13 +171,13 @@ The document templates directory. The context of this constant (All Users or Cur
|
|||
|
||||
\e{$APPDATA}
|
||||
|
||||
The application data directory. Detection of the current user path requires Internet Explorer 4 and above. Detection of the all users path requires Internet Explorer 5 and above. The context of this constant (All Users or Current user) depends on the \R{setshellvarcontext}{SetShellVarContext} setting. The default is the current user.
|
||||
The (roaming) application data directory.\#{ Detection of the current user path requires Internet Explorer 4 and above. Detection of the all users path requires Internet Explorer 5 and above. The context of this constant (All Users or Current user) depends on the \R{setshellvarcontext}{SetShellVarContext} setting. The default is the current user.}
|
||||
|
||||
This constant is not available on Windows 95 unless Internet Explorer 4 with Active Desktop is installed.
|
||||
|
||||
\e{$LOCALAPPDATA}
|
||||
|
||||
The local (non-roaming) application data directory. The context of this constant (All Users or Current user) depends on the \R{setshellvarcontext}{SetShellVarContext} setting. The default is the current user.
|
||||
The local (non-roaming) application data directory. The context of this constant (All Users or Current user) depends on the \R{setshellvarcontext}{SetShellVarContext} setting. The default is the current user. The All Users location is also known as \cw{%ProgramData%} on Vista and above.
|
||||
|
||||
This constant is available on Windows ME, 2000 and above.
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ examples = Split("""
|
|||
FileFuncTest.nsi
|
||||
gfx.nsi
|
||||
install-per-user.nsi
|
||||
install-shared.nsi
|
||||
languages.nsi
|
||||
Library.nsi
|
||||
LogicLib.nsi
|
||||
|
|
|
@ -14,7 +14,7 @@ folders inside the users profile.
|
|||
!define NAME "Per-User example"
|
||||
!define REGPATH_UNINSTSUBKEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}"
|
||||
Name "${NAME}"
|
||||
OutFile "${NAME}.exe"
|
||||
OutFile "Install ${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
|
||||
|
|
84
Examples/install-shared.nsi
Normal file
84
Examples/install-shared.nsi
Normal file
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
|
||||
This example script installs a simple application for all users on a machine.
|
||||
|
||||
All-users installers should only write to HKLM, $ProgramFiles, $CommonFiles and the
|
||||
"All context" versions of $LocalAppData, $Templates, $SMPrograms etc.
|
||||
|
||||
It should not write to HKCU nor any folders in the users profile!
|
||||
If the application requires writable template data in $AppData it
|
||||
must copy the required files from a shared location the
|
||||
first time a user launches the application.
|
||||
|
||||
*/
|
||||
|
||||
!define NAME "All-users example"
|
||||
!define REGPATH_UNINSTSUBKEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}"
|
||||
Name "${NAME}"
|
||||
OutFile "Install ${NAME}.exe"
|
||||
Unicode True
|
||||
RequestExecutionLevel Admin ; Request admin rights on WinVista+ (when UAC is turned on)
|
||||
InstallDir "$ProgramFiles\$(^Name)"
|
||||
InstallDirRegKey HKLM "${REGPATH_UNINSTSUBKEY}" "UninstallString"
|
||||
|
||||
Page Directory
|
||||
Page InstFiles
|
||||
|
||||
Uninstpage UninstConfirm
|
||||
Uninstpage InstFiles
|
||||
|
||||
!include LogicLib.nsh
|
||||
|
||||
!macro EnsureAdminRights
|
||||
UserInfo::GetAccountType
|
||||
Pop $0
|
||||
${If} $0 != "admin" ; Require admin rights on WinNT4+
|
||||
MessageBox MB_IconStop "Administrator rights required!"
|
||||
SetErrorLevel 740 ; ERROR_ELEVATION_REQUIRED
|
||||
Quit
|
||||
${EndIf}
|
||||
!macroend
|
||||
|
||||
Function .onInit
|
||||
SetShellVarContext All
|
||||
!insertmacro EnsureAdminRights
|
||||
FunctionEnd
|
||||
|
||||
Function un.onInit
|
||||
SetShellVarContext All
|
||||
!insertmacro EnsureAdminRights
|
||||
FunctionEnd
|
||||
|
||||
|
||||
Section "Program files (Required)"
|
||||
SectionIn Ro
|
||||
|
||||
SetOutPath $InstDir
|
||||
WriteUninstaller "$InstDir\Uninst.exe"
|
||||
WriteRegStr HKLM "${REGPATH_UNINSTSUBKEY}" "DisplayName" "${NAME}"
|
||||
WriteRegStr HKLM "${REGPATH_UNINSTSUBKEY}" "UninstallString" '"$InstDir\Uninst.exe"'
|
||||
WriteRegDWORD HKLM "${REGPATH_UNINSTSUBKEY}" "NoModify" 1
|
||||
WriteRegDWORD HKLM "${REGPATH_UNINSTSUBKEY}" "NoRepair" 1
|
||||
|
||||
File "/oname=$InstDir\MyApp.exe" "${NSISDIR}\Bin\MakeLangId.exe" ; Pretend that we have a real application to install
|
||||
|
||||
;WriteRegStr HKLM "Software\Classes\.myfileext" "myfiletype"
|
||||
;WriteRegStr HKLM "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 HKLM "${REGPATH_UNINSTSUBKEY}"
|
||||
;DeleteRegKey HKLM "Software\Classes\myfiletype\shell\myapp"
|
||||
;DeleteRegKey /IfEmpty HKLM "Software\Classes\myfiletype\shell"
|
||||
;DeleteRegKey /IfEmpty HKLM "Software\Classes\myfiletype"
|
||||
|
||||
Delete "$SMPrograms\${NAME}.lnk"
|
||||
SectionEnd
|
|
@ -312,6 +312,7 @@ ${MementoSection} "Script Examples" SecExample
|
|||
File ..\Examples\example1.nsi
|
||||
File ..\Examples\example2.nsi
|
||||
File ..\Examples\install-per-user.nsi
|
||||
File ..\Examples\install-shared.nsi
|
||||
File ..\Examples\viewhtml.nsi
|
||||
File ..\Examples\waplugin.nsi
|
||||
File ..\Examples\bigtest.nsi
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue