diff --git a/Docs/src/var.but b/Docs/src/var.but index 1dadabd9..fe160b8d 100644 --- a/Docs/src/var.but +++ b/Docs/src/var.but @@ -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. diff --git a/Examples/SConscript b/Examples/SConscript index c1c226ae..095efe89 100644 --- a/Examples/SConscript +++ b/Examples/SConscript @@ -7,6 +7,7 @@ examples = Split(""" FileFuncTest.nsi gfx.nsi install-per-user.nsi + install-shared.nsi languages.nsi Library.nsi LogicLib.nsi diff --git a/Examples/install-per-user.nsi b/Examples/install-per-user.nsi index f119b004..85128135 100644 --- a/Examples/install-per-user.nsi +++ b/Examples/install-per-user.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 diff --git a/Examples/install-shared.nsi b/Examples/install-shared.nsi new file mode 100644 index 00000000..df52eeaf --- /dev/null +++ b/Examples/install-shared.nsi @@ -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 diff --git a/Examples/makensis.nsi b/Examples/makensis.nsi index 9a90c924..10bcb2bc 100644 --- a/Examples/makensis.nsi +++ b/Examples/makensis.nsi @@ -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