11
11
!define INSTDIR_REG_ROOT " HKLM"
12
12
!define INSTDIR_REG_KEY " Software\Microsoft\Windows\CurrentVersion\Uninstall\PC-BASIC"
13
13
14
- ; --------------------------------
15
- ; Include Modern UI
16
14
15
+ ; multiuser, modern UI
16
+
17
+ !define MULTIUSER_EXECUTIONLEVEL Highest
18
+ !define MULTIUSER_MUI
19
+ !define MULTIUSER_INSTALLMODE_COMMANDLINE
20
+ !define MULTIUSER_INSTALLMODE_INSTDIR " PC-BASIC"
21
+ !include " MultiUser.nsh"
17
22
!include " MUI2.nsh"
18
23
!include " AdvUninstLog.nsh"
19
24
;
25
30
Name " PC-BASIC 3.23"
26
31
OutFile " pcbasic-win32.exe"
27
32
28
-
29
-
30
-
31
-
32
-
33
- ; Default installation folder
34
- InstallDir " $programfiles\PC-BASIC"
35
- ; Get installation folder from registry if available
36
- InstallDirRegKey ${INSTDIR_REG_ROOT} " ${INSTDIR_REG_KEY}" " InstallDir"
37
-
38
- ; Request application privileges for Windows Vista
39
- ; RequestExecutionLevel user
40
-
41
- RequestExecutionLevel admin ; Require admin rights on NT6+ (When UAC is turned on)
42
-
43
33
!include LogicLib.nsh
44
34
45
35
@@ -53,6 +43,8 @@ RequestExecutionLevel admin ;Require admin rights on NT6+ (When UAC is turned on
53
43
; Variables
54
44
55
45
Var StartMenuFolder
46
+ Var Shortcuts
47
+
56
48
57
49
; --------------------------------
58
50
; Interface Settings
@@ -67,6 +59,9 @@ Var StartMenuFolder
67
59
; --------------------------------
68
60
; Pages
69
61
62
+
63
+ !insertmacro MULTIUSER_PAGE_INSTALLMODE
64
+
70
65
!insertmacro UNATTENDED_UNINSTALL
71
66
; !insertmacro INTERACTIVE_UNINSTALL
72
67
@@ -107,37 +102,21 @@ Section "PC-BASIC" SecDummy
107
102
SetOutPath " $PROFILE"
108
103
CreateShortCut " $SMPROGRAMS\$StartMenuFolder\PC-BASIC.lnk" " $INSTDIR\pcbasic.exe"
109
104
105
+ ; workaround as multiuser doesn't seem to get the right location for shortcuts if an admin user installs 'just for me'
106
+ WriteRegStr HKCU " Software\PC-BASIC" " Shortcuts" " $SMPROGRAMS\$StartMenuFolder"
107
+
110
108
111
109
!insertmacro MUI_STARTMENU_WRITE_END
112
110
SectionEnd
113
111
114
- ; --------------------------------
115
- ; Descriptions
116
-
117
- ; Language strings
118
- ; LangString DESC_SecDummy ${LANG_ENGLISH} "Main section."
119
-
120
- ; Assign language strings to sections
121
- ; !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
122
- ; !insertmacro MUI_DESCRIPTION_TEXT ${SecDummy} $(DESC_SecDummy)
123
- ; !insertmacro MUI_FUNCTION_DESCRIPTION_END
124
-
125
-
126
112
; --------------------------------
127
113
; Uninstaller Section
128
114
129
115
130
116
Function .onInit
131
- ; prepare log always within .onInit function
132
-
133
- UserInfo::GetAccountType
134
- pop $0
135
- ${If} $0 != " admin" ; Require admin rights on NT4+
136
- MessageBox mb_iconstop " The PC-BASIC installer requires administrator rights, which you appear not to have."
137
- SetErrorLevel 740 ; ERROR_ELEVATION_REQUIRED
138
- Quit
139
- ${EndIf}
117
+ !insertmacro MULTIUSER_INIT
140
118
119
+ ; prepare log always within .onInit function
141
120
!insertmacro UNINSTALL.LOG_PREPARE_INSTALL
142
121
FunctionEnd
143
122
@@ -155,16 +134,23 @@ Section UnInstall
155
134
!insertmacro UNINSTALL.LOG_END_UNINSTALL
156
135
157
136
!insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder
158
- Delete " $SMPROGRAMS\$StartMenuFolder\PC-BASIC.lnk"
159
- Delete " $SMPROGRAMS\$StartMenuFolder\Documentation.lnk"
160
- Delete " $SMPROGRAMS\$StartMenuFolder\Uninstall.lnk"
161
- RMDir " $SMPROGRAMS\$StartMenuFolder"
137
+
138
+ ; workaround as multiuser doesn't seem to get the right location for shortcuts if an admin user installs 'just for me'
139
+ ReadRegStr $Shortcuts HKCU " Software\PC-BASIC" " Shortcuts"
140
+
141
+ Delete " $Shortcuts\PC-BASIC.lnk"
142
+ Delete " $Shortcuts\Documentation.lnk"
143
+ Delete " $Shortcuts\Uninstall.lnk"
144
+ RMDir " $Shortcuts"
162
145
163
- DeleteRegKey /ifempty HKCU " Software\PC-BASIC"
146
+ DeleteRegKey HKCU " Software\PC-BASIC"
147
+ ; DeleteRegKey /ifempty HKCU "Software\PC-BASIC"
164
148
SectionEnd
165
149
166
150
167
151
Function UN.onInit
152
+ !insertmacro MULTIUSER_UNINIT
153
+
168
154
; begin uninstall, could be added on top of uninstall section instead
169
155
!insertmacro UNINSTALL.LOG_BEGIN_UNINSTALL
170
156
FunctionEnd
0 commit comments