Debian Codegraph @

Examples/MultiUser.nsi

raw
1 Name "MultiUser example"
2 OutFile "MultiUser.exe"
3
4 !define UNINSTKEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)"
5 !define MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY "${UNINSTKEY}"
6 !define MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_VALUENAME "CurrentUser"
7 !define MULTIUSER_INSTALLMODE_INSTDIR "$(^Name)"
8 !define MULTIUSER_INSTALLMODE_COMMANDLINE
9 !define MULTIUSER_EXECUTIONLEVEL Highest
10 !define MULTIUSER_MUI
11
12 !include "LogicLib.nsh"
13 !include "MultiUser.nsh"
14 !include "MUI2.nsh"
15
16 !insertmacro MUI_PAGE_WELCOME
17 !insertmacro MULTIUSER_PAGE_INSTALLMODE
18 !insertmacro MUI_PAGE_DIRECTORY
19 !insertmacro MUI_PAGE_INSTFILES
20 !insertmacro MUI_PAGE_FINISH
21
22 !insertmacro MUI_UNPAGE_CONFIRM
23 !insertmacro MUI_UNPAGE_INSTFILES
24 !insertmacro MUI_LANGUAGE "English"
25
26 Function .onInit
27 !insertmacro MULTIUSER_INIT
28 FunctionEnd
29
30 Function un.onInit
31 !insertmacro MULTIUSER_UNINIT
32 FunctionEnd
33
34 Section
35 SetOutPath "$InstDir"
36 WriteUninstaller "$InstDir\Uninstall.exe"
37 WriteRegStr ShCtx "${UNINSTKEY}" DisplayName "$(^Name)"
38 WriteRegStr ShCtx "${UNINSTKEY}" UninstallString '"$InstDir\Uninstall.exe"'
39 WriteRegStr ShCtx "${UNINSTKEY}" $MultiUser.InstallMode 1 ; Write MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_VALUENAME so the correct context can be detected in the uninstaller.
40
41 !tempfile APP
42 !makensis '-v2 "-DOUTFILE=${APP}" "-DNAME=NsisMultiUserExample" -DCOMPANY=Nullsoft "AppGen.nsi"' = 0
43 File "/oname=$InstDir\MyApp.exe" "${APP}" ; Pretend that we have a real application to install
44 !delfile "${APP}"
45 SectionEnd
46
47 Section "Start Menu shortcut"
48 CreateShortcut /NoWorkingDir "$SMPrograms\$(^Name).lnk" "$InstDir\MyApp.exe"
49 SectionEnd
50
51 Section "-Uninstall"
52 Delete "$SMPrograms\$(^Name).lnk"
53
54 Delete "$InstDir\MyApp.exe"
55 Delete "$InstDir\Uninstall.exe"
56 DeleteRegKey ShCtx "${UNINSTKEY}"
57 RMDir $InstDir
58 SectionEnd