Statistiques
| Révision :

root / tmp / org.txm.setups / nsis / Include / MultiUser.nsh @ 3088

Historique | Voir | Annoter | Télécharger (14,75 ko)

1 728 mdecorde
/*
2 728 mdecorde
3 728 mdecorde
MultiUser.nsh
4 728 mdecorde
5 728 mdecorde
Installer configuration for multi-user Windows environments
6 728 mdecorde
7 2956 mdecorde
Copyright 2008-2020 Joost Verburg
8 728 mdecorde
9 728 mdecorde
*/
10 728 mdecorde
11 728 mdecorde
!ifndef MULTIUSER_INCLUDED
12 2956 mdecorde
!define MULTIUSER_INCLUDED 20200319
13 2956 mdecorde
!verbose push 3
14 728 mdecorde
15 728 mdecorde
;Standard NSIS header files
16 728 mdecorde
17 728 mdecorde
!ifdef MULTIUSER_MUI
18 728 mdecorde
  !include MUI2.nsh
19 728 mdecorde
!endif
20 728 mdecorde
!include LogicLib.nsh
21 728 mdecorde
!include WinVer.nsh
22 728 mdecorde
!include FileFunc.nsh
23 728 mdecorde
24 2956 mdecorde
!if ${NSIS_PTR_SIZE} > 4
25 2956 mdecorde
!define /IfNDef MULTIUSER_MINWIN 0x501
26 2956 mdecorde
!else
27 2956 mdecorde
!define /IfNDef MULTIUSER_MINWIN 0x400
28 2956 mdecorde
!endif
29 2956 mdecorde
30 728 mdecorde
;Variables
31 728 mdecorde
32 728 mdecorde
Var MultiUser.Privileges
33 728 mdecorde
Var MultiUser.InstallMode
34 728 mdecorde
35 728 mdecorde
;Command line installation mode setting
36 728 mdecorde
37 728 mdecorde
!ifdef MULTIUSER_INSTALLMODE_COMMANDLINE
38 728 mdecorde
  !include StrFunc.nsh
39 728 mdecorde
  !ifndef StrStr_INCLUDED
40 728 mdecorde
    ${StrStr}
41 728 mdecorde
  !endif
42 728 mdecorde
  !ifndef MULTIUSER_NOUNINSTALL
43 728 mdecorde
    !ifndef UnStrStr_INCLUDED
44 728 mdecorde
      ${UnStrStr}
45 728 mdecorde
    !endif
46 728 mdecorde
  !endif
47 728 mdecorde
48 728 mdecorde
  Var MultiUser.Parameters
49 728 mdecorde
  Var MultiUser.Result
50 728 mdecorde
!endif
51 728 mdecorde
52 728 mdecorde
;Installation folder stored in registry
53 728 mdecorde
54 728 mdecorde
!ifdef MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY & MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUENAME
55 728 mdecorde
  Var MultiUser.InstDir
56 728 mdecorde
!endif
57 728 mdecorde
58 728 mdecorde
!ifdef MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY & MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_VALUENAME
59 728 mdecorde
  Var MultiUser.DefaultKeyValue
60 728 mdecorde
!endif
61 728 mdecorde
62 728 mdecorde
;Windows Vista UAC setting
63 728 mdecorde
64 728 mdecorde
!if "${MULTIUSER_EXECUTIONLEVEL}" == Admin
65 728 mdecorde
  RequestExecutionLevel admin
66 728 mdecorde
  !define MULTIUSER_EXECUTIONLEVEL_ALLUSERS
67 728 mdecorde
!else if "${MULTIUSER_EXECUTIONLEVEL}" == Power
68 728 mdecorde
  RequestExecutionLevel admin
69 728 mdecorde
  !define MULTIUSER_EXECUTIONLEVEL_ALLUSERS
70 728 mdecorde
!else if "${MULTIUSER_EXECUTIONLEVEL}" == Highest
71 728 mdecorde
  RequestExecutionLevel highest
72 728 mdecorde
  !define MULTIUSER_EXECUTIONLEVEL_ALLUSERS
73 728 mdecorde
!else
74 728 mdecorde
  RequestExecutionLevel user
75 2956 mdecorde
  !ifndef MULTIUSER_EXECUTIONLEVEL
76 2956 mdecorde
    !warning "MULTIUSER_EXECUTIONLEVEL not set!"
77 2956 mdecorde
  !endif
78 728 mdecorde
!endif
79 728 mdecorde
80 728 mdecorde
/*
81 728 mdecorde
82 728 mdecorde
Install modes
83 728 mdecorde
84 728 mdecorde
*/
85 728 mdecorde
86 728 mdecorde
!macro MULTIUSER_INSTALLMODE_ALLUSERS UNINSTALLER_PREFIX UNINSTALLER_FUNCPREFIX
87 728 mdecorde
88 728 mdecorde
  ;Install mode initialization - per-machine
89 728 mdecorde
90 728 mdecorde
  ${ifnot} ${IsNT}
91 728 mdecorde
    ${orif} $MultiUser.Privileges == "Admin"
92 728 mdecorde
    ${orif} $MultiUser.Privileges == "Power"
93 728 mdecorde
94 728 mdecorde
    StrCpy $MultiUser.InstallMode AllUsers
95 728 mdecorde
96 728 mdecorde
    SetShellVarContext all
97 728 mdecorde
98 728 mdecorde
    !if "${UNINSTALLER_PREFIX}" != UN
99 728 mdecorde
      ;Set default installation location for installer
100 728 mdecorde
      !ifdef MULTIUSER_INSTALLMODE_INSTDIR
101 2956 mdecorde
        !ifdef MULTIUSER_USE_PROGRAMFILES64
102 2956 mdecorde
          StrCpy $INSTDIR "$PROGRAMFILES64\${MULTIUSER_INSTALLMODE_INSTDIR}"
103 2956 mdecorde
        !else
104 2956 mdecorde
          StrCpy $INSTDIR "$PROGRAMFILES\${MULTIUSER_INSTALLMODE_INSTDIR}"
105 2956 mdecorde
        !endif
106 728 mdecorde
      !endif
107 728 mdecorde
    !endif
108 728 mdecorde
109 728 mdecorde
    !ifdef MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY & MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUENAME
110 728 mdecorde
111 728 mdecorde
      ReadRegStr $MultiUser.InstDir HKLM "${MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY}" "${MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUENAME}"
112 728 mdecorde
113 728 mdecorde
      ${if} $MultiUser.InstDir != ""
114 728 mdecorde
        StrCpy $INSTDIR $MultiUser.InstDir
115 728 mdecorde
      ${endif}
116 728 mdecorde
117 728 mdecorde
    !endif
118 728 mdecorde
119 728 mdecorde
    !ifdef MULTIUSER_INSTALLMODE_${UNINSTALLER_PREFIX}FUNCTION
120 728 mdecorde
      Call "${MULTIUSER_INSTALLMODE_${UNINSTALLER_PREFIX}FUNCTION}"
121 728 mdecorde
    !endif
122 728 mdecorde
123 728 mdecorde
  ${endif}
124 728 mdecorde
125 728 mdecorde
!macroend
126 728 mdecorde
127 728 mdecorde
!macro MULTIUSER_INSTALLMODE_CURRENTUSER UNINSTALLER_PREFIX UNINSTALLER_FUNCPREFIX
128 728 mdecorde
129 728 mdecorde
  ;Install mode initialization - per-user
130 2956 mdecorde
131 2956 mdecorde
  !if ${MULTIUSER_MINWIN} < 0x500
132 2956 mdecorde
  ${if} ${IsNT}
133 2956 mdecorde
  !endif
134 2956 mdecorde
135 728 mdecorde
    StrCpy $MultiUser.InstallMode CurrentUser
136 728 mdecorde
    SetShellVarContext current
137 728 mdecorde
138 728 mdecorde
    !if "${UNINSTALLER_PREFIX}" != UN
139 728 mdecorde
      ;Set default installation location for installer
140 728 mdecorde
      !ifdef MULTIUSER_INSTALLMODE_INSTDIR
141 2956 mdecorde
        !if ${MULTIUSER_MINWIN} < 0x490
142 728 mdecorde
        ${if} ${AtLeastWin2000}
143 2956 mdecorde
        !endif
144 2956 mdecorde
          GetKnownFolderPath $INSTDIR {5CD7AEE2-2219-4A67-B85D-6C9CE15660CB} ; FOLDERID_UserProgramFiles
145 2956 mdecorde
          StrCmp $INSTDIR "" 0 +2
146 2956 mdecorde
          StrCpy $INSTDIR "$LocalAppData\Programs" ; Fallback directory
147 2956 mdecorde
          StrCpy $INSTDIR "$INSTDIR\${MULTIUSER_INSTALLMODE_INSTDIR}"
148 2956 mdecorde
        !if ${MULTIUSER_MINWIN} < 0x490
149 728 mdecorde
        ${else}
150 728 mdecorde
          StrCpy $INSTDIR "$PROGRAMFILES\${MULTIUSER_INSTALLMODE_INSTDIR}"
151 728 mdecorde
        ${endif}
152 2956 mdecorde
        !endif
153 728 mdecorde
      !endif
154 728 mdecorde
    !endif
155 728 mdecorde
156 728 mdecorde
    !ifdef MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY & MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUENAME
157 728 mdecorde
      ReadRegStr $MultiUser.InstDir HKCU "${MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY}" "${MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUENAME}"
158 728 mdecorde
      ${if} $MultiUser.InstDir != ""
159 728 mdecorde
        StrCpy $INSTDIR $MultiUser.InstDir
160 728 mdecorde
      ${endif}
161 728 mdecorde
    !endif
162 2956 mdecorde
163 728 mdecorde
    !ifdef MULTIUSER_INSTALLMODE_${UNINSTALLER_PREFIX}FUNCTION
164 728 mdecorde
      Call "${MULTIUSER_INSTALLMODE_${UNINSTALLER_PREFIX}FUNCTION}"
165 728 mdecorde
    !endif
166 2956 mdecorde
167 2956 mdecorde
  !if ${MULTIUSER_MINWIN} < 0x500
168 728 mdecorde
  ${endif}
169 2956 mdecorde
  !endif
170 728 mdecorde
171 728 mdecorde
!macroend
172 728 mdecorde
173 728 mdecorde
Function MultiUser.InstallMode.AllUsers
174 728 mdecorde
  !insertmacro MULTIUSER_INSTALLMODE_ALLUSERS "" ""
175 728 mdecorde
FunctionEnd
176 728 mdecorde
177 728 mdecorde
Function MultiUser.InstallMode.CurrentUser
178 728 mdecorde
  !insertmacro MULTIUSER_INSTALLMODE_CURRENTUSER "" ""
179 728 mdecorde
FunctionEnd
180 728 mdecorde
181 728 mdecorde
!ifndef MULTIUSER_NOUNINSTALL
182 728 mdecorde
183 728 mdecorde
Function un.MultiUser.InstallMode.AllUsers
184 728 mdecorde
  !insertmacro MULTIUSER_INSTALLMODE_ALLUSERS UN .un
185 728 mdecorde
FunctionEnd
186 728 mdecorde
187 728 mdecorde
Function un.MultiUser.InstallMode.CurrentUser
188 728 mdecorde
  !insertmacro MULTIUSER_INSTALLMODE_CURRENTUSER UN .un
189 728 mdecorde
FunctionEnd
190 728 mdecorde
191 728 mdecorde
!endif
192 728 mdecorde
193 728 mdecorde
/*
194 728 mdecorde
195 728 mdecorde
Installer/uninstaller initialization
196 728 mdecorde
197 728 mdecorde
*/
198 728 mdecorde
199 728 mdecorde
!macro MULTIUSER_INIT_QUIT UNINSTALLER_FUNCPREFIX
200 728 mdecorde
201 728 mdecorde
  !ifdef MULTIUSER_INIT_${UNINSTALLER_FUNCPREFIX}FUNCTIONQUIT
202 2956 mdecorde
    Call "${MULTIUSER_INIT_${UNINSTALLER_FUNCPREFIX}FUNCTIONQUIT}"
203 728 mdecorde
  !else
204 728 mdecorde
    Quit
205 728 mdecorde
  !endif
206 728 mdecorde
207 728 mdecorde
!macroend
208 728 mdecorde
209 2956 mdecorde
!macro MULTIUSER_INIT_TEXTS UNINSTALLER_PREFIX
210 728 mdecorde
211 2956 mdecorde
  !if "${UNINSTALLER_PREFIX}" == ""
212 2956 mdecorde
    !define /ReDef MULTIUSER_TMPSTR_CAPTION "$(^SetupCaption)"
213 2956 mdecorde
  !else
214 2956 mdecorde
    !define /ReDef MULTIUSER_TMPSTR_CAPTION "$(^Name)"
215 728 mdecorde
  !endif
216 728 mdecorde
217 2956 mdecorde
  !define /IfNDef MULTIUSER_INIT_TEXT_ADMINREQUIRED "${MULTIUSER_TMPSTR_CAPTION} requires administrator privileges."
218 2956 mdecorde
  !define /IfNDef MULTIUSER_INIT_TEXT_POWERREQUIRED "${MULTIUSER_TMPSTR_CAPTION} requires at least Power User privileges."
219 2956 mdecorde
  !define /IfNDef MULTIUSER_INIT_TEXT_ALLUSERSNOTPOSSIBLE "Your user account does not have sufficient privileges to install $(^Name) for all users of this computer."
220 728 mdecorde
221 2956 mdecorde
  !undef MULTIUSER_TMPSTR_CAPTION
222 728 mdecorde
223 728 mdecorde
!macroend
224 728 mdecorde
225 728 mdecorde
!macro MULTIUSER_INIT_CHECKS UNINSTALLER_PREFIX UNINSTALLER_FUNCPREFIX
226 728 mdecorde
227 728 mdecorde
  ;Installer initialization - check privileges and set install mode
228 728 mdecorde
229 2956 mdecorde
  !insertmacro MULTIUSER_INIT_TEXTS "${UNINSTALLER_PREFIX}"
230 728 mdecorde
231 728 mdecorde
  UserInfo::GetAccountType
232 728 mdecorde
  Pop $MultiUser.Privileges
233 728 mdecorde
234 2956 mdecorde
  !if ${MULTIUSER_MINWIN} < 0x500
235 728 mdecorde
  ${if} ${IsNT}
236 2956 mdecorde
  !endif
237 728 mdecorde
238 728 mdecorde
    ;Check privileges
239 728 mdecorde
240 728 mdecorde
    !if "${MULTIUSER_EXECUTIONLEVEL}" == Admin
241 728 mdecorde
242 728 mdecorde
      ${if} $MultiUser.Privileges != "Admin"
243 728 mdecorde
        MessageBox MB_OK|MB_ICONSTOP "${MULTIUSER_INIT_TEXT_ADMINREQUIRED}"
244 728 mdecorde
        !insertmacro MULTIUSER_INIT_QUIT "${UNINSTALLER_FUNCPREFIX}"
245 728 mdecorde
      ${endif}
246 728 mdecorde
247 728 mdecorde
    !else if "${MULTIUSER_EXECUTIONLEVEL}" == Power
248 728 mdecorde
249 728 mdecorde
      ${if} $MultiUser.Privileges != "Power"
250 728 mdecorde
        ${andif} $MultiUser.Privileges != "Admin"
251 728 mdecorde
        ${if} ${AtMostWinXP}
252 728 mdecorde
           MessageBox MB_OK|MB_ICONSTOP "${MULTIUSER_INIT_TEXT_POWERREQUIRED}"
253 728 mdecorde
        ${else}
254 728 mdecorde
           MessageBox MB_OK|MB_ICONSTOP "${MULTIUSER_INIT_TEXT_ADMINREQUIRED}"
255 728 mdecorde
        ${endif}
256 728 mdecorde
        !insertmacro MULTIUSER_INIT_QUIT "${UNINSTALLER_FUNCPREFIX}"
257 728 mdecorde
      ${endif}
258 728 mdecorde
259 728 mdecorde
    !endif
260 728 mdecorde
261 728 mdecorde
    !ifdef MULTIUSER_EXECUTIONLEVEL_ALLUSERS
262 728 mdecorde
263 728 mdecorde
      ;Default to per-machine installation if possible
264 728 mdecorde
265 728 mdecorde
      ${if} $MultiUser.Privileges == "Admin"
266 728 mdecorde
        ${orif} $MultiUser.Privileges == "Power"
267 728 mdecorde
        !ifndef MULTIUSER_INSTALLMODE_DEFAULT_CURRENTUSER
268 728 mdecorde
          Call ${UNINSTALLER_FUNCPREFIX}MultiUser.InstallMode.AllUsers
269 728 mdecorde
        !else
270 728 mdecorde
          Call ${UNINSTALLER_FUNCPREFIX}MultiUser.InstallMode.CurrentUser
271 728 mdecorde
        !endif
272 728 mdecorde
273 728 mdecorde
        !ifdef MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY & MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_VALUENAME
274 728 mdecorde
275 728 mdecorde
          ;Set installation mode to setting from a previous installation
276 728 mdecorde
277 728 mdecorde
          !ifndef MULTIUSER_INSTALLMODE_DEFAULT_CURRENTUSER
278 728 mdecorde
            ReadRegStr $MultiUser.DefaultKeyValue HKLM "${MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY}" "${MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_VALUENAME}"
279 728 mdecorde
            ${if} $MultiUser.DefaultKeyValue == ""
280 728 mdecorde
              ReadRegStr $MultiUser.DefaultKeyValue HKCU "${MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY}" "${MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_VALUENAME}"
281 728 mdecorde
              ${if} $MultiUser.DefaultKeyValue != ""
282 728 mdecorde
                Call ${UNINSTALLER_FUNCPREFIX}MultiUser.InstallMode.CurrentUser
283 728 mdecorde
              ${endif}
284 728 mdecorde
            ${endif}
285 728 mdecorde
          !else
286 728 mdecorde
            ReadRegStr $MultiUser.DefaultKeyValue HKCU "${MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY}" "${MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_VALUENAME}"
287 728 mdecorde
            ${if} $MultiUser.DefaultKeyValue == ""
288 728 mdecorde
              ReadRegStr $MultiUser.DefaultKeyValue HKLM "${MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY}" "${MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_VALUENAME}"
289 728 mdecorde
              ${if} $MultiUser.DefaultKeyValue != ""
290 728 mdecorde
                Call ${UNINSTALLER_FUNCPREFIX}MultiUser.InstallMode.AllUsers
291 728 mdecorde
              ${endif}
292 728 mdecorde
            ${endif}
293 728 mdecorde
          !endif
294 728 mdecorde
295 728 mdecorde
        !endif
296 728 mdecorde
297 728 mdecorde
      ${else}
298 728 mdecorde
        Call ${UNINSTALLER_FUNCPREFIX}MultiUser.InstallMode.CurrentUser
299 728 mdecorde
      ${endif}
300 728 mdecorde
301 728 mdecorde
    !else
302 728 mdecorde
303 728 mdecorde
      Call ${UNINSTALLER_FUNCPREFIX}MultiUser.InstallMode.CurrentUser
304 728 mdecorde
305 728 mdecorde
    !endif
306 728 mdecorde
307 728 mdecorde
    !ifdef MULTIUSER_INSTALLMODE_COMMANDLINE
308 728 mdecorde
309 728 mdecorde
      ;Check for install mode setting on command line
310 728 mdecorde
311 728 mdecorde
      ${${UNINSTALLER_FUNCPREFIX}GetParameters} $MultiUser.Parameters
312 728 mdecorde
313 728 mdecorde
      ${${UNINSTALLER_PREFIX}StrStr} $MultiUser.Result $MultiUser.Parameters "/CurrentUser"
314 728 mdecorde
315 728 mdecorde
      ${if} $MultiUser.Result != ""
316 728 mdecorde
        Call ${UNINSTALLER_FUNCPREFIX}MultiUser.InstallMode.CurrentUser
317 728 mdecorde
      ${endif}
318 728 mdecorde
319 728 mdecorde
      ${${UNINSTALLER_PREFIX}StrStr} $MultiUser.Result $MultiUser.Parameters "/AllUsers"
320 728 mdecorde
321 728 mdecorde
      ${if} $MultiUser.Result != ""
322 728 mdecorde
        ${if} $MultiUser.Privileges == "Admin"
323 728 mdecorde
          ${orif} $MultiUser.Privileges == "Power"
324 728 mdecorde
          Call ${UNINSTALLER_FUNCPREFIX}MultiUser.InstallMode.AllUsers
325 728 mdecorde
        ${else}
326 728 mdecorde
          MessageBox MB_OK|MB_ICONSTOP "${MULTIUSER_INIT_TEXT_ALLUSERSNOTPOSSIBLE}"
327 728 mdecorde
        ${endif}
328 728 mdecorde
      ${endif}
329 728 mdecorde
330 728 mdecorde
    !endif
331 2956 mdecorde
332 2956 mdecorde
  !if ${MULTIUSER_MINWIN} < 0x500
333 728 mdecorde
  ${else}
334 728 mdecorde
335 728 mdecorde
    ;Not running Windows NT, per-user installation not supported
336 728 mdecorde
    Call ${UNINSTALLER_FUNCPREFIX}MultiUser.InstallMode.AllUsers
337 2956 mdecorde
338 728 mdecorde
  ${endif}
339 2956 mdecorde
  !endif
340 728 mdecorde
341 728 mdecorde
!macroend
342 728 mdecorde
343 728 mdecorde
!macro MULTIUSER_INIT
344 2956 mdecorde
  !verbose push 3
345 2956 mdecorde
  !ifdef __UNINSTALL__
346 2956 mdecorde
    !insertmacro MULTIUSER_UNINIT
347 2956 mdecorde
  !else
348 2956 mdecorde
    !insertmacro MULTIUSER_INIT_CHECKS "" ""
349 2956 mdecorde
  !endif
350 728 mdecorde
  !verbose pop
351 728 mdecorde
!macroend
352 728 mdecorde
353 728 mdecorde
!ifndef MULTIUSER_NOUNINSTALL
354 728 mdecorde
!macro MULTIUSER_UNINIT
355 2956 mdecorde
  !verbose push 3
356 728 mdecorde
  !insertmacro MULTIUSER_INIT_CHECKS Un un.
357 728 mdecorde
  !verbose pop
358 728 mdecorde
!macroend
359 728 mdecorde
!endif
360 728 mdecorde
361 728 mdecorde
/*
362 728 mdecorde
363 2956 mdecorde
Mode selection page
364 728 mdecorde
365 728 mdecorde
*/
366 728 mdecorde
367 2956 mdecorde
!macro MULTIUSER_PAGE_FUNCTION_CUSTOM TYPE
368 2956 mdecorde
  !ifmacrodef MUI_PAGE_FUNCTION_CUSTOM
369 2956 mdecorde
    !insertmacro MUI_PAGE_FUNCTION_CUSTOM "${TYPE}"
370 2956 mdecorde
  !endif
371 2956 mdecorde
  !ifdef MULTIUSER_PAGE_CUSTOMFUNCTION_${TYPE}
372 2956 mdecorde
    Call "${MULTIUSER_PAGE_CUSTOMFUNCTION_${TYPE}}"
373 2956 mdecorde
    !undef MULTIUSER_PAGE_CUSTOMFUNCTION_${TYPE}
374 2956 mdecorde
  !endif
375 2956 mdecorde
!macroend
376 728 mdecorde
377 728 mdecorde
!macro MULTIUSER_INSTALLMODEPAGE_INTERFACE
378 728 mdecorde
379 728 mdecorde
  !ifndef MULTIUSER_INSTALLMODEPAGE_INTERFACE
380 728 mdecorde
    !define MULTIUSER_INSTALLMODEPAGE_INTERFACE
381 728 mdecorde
    Var MultiUser.InstallModePage
382 728 mdecorde
383 728 mdecorde
    Var MultiUser.InstallModePage.Text
384 728 mdecorde
385 728 mdecorde
    Var MultiUser.InstallModePage.AllUsers
386 728 mdecorde
    Var MultiUser.InstallModePage.CurrentUser
387 2956 mdecorde
388 728 mdecorde
  !endif
389 728 mdecorde
390 728 mdecorde
!macroend
391 728 mdecorde
392 2956 mdecorde
!macro MULTIUSER_PAGEDECLARATION_INSTALLMODE UNPREFIX UNIQUEID
393 728 mdecorde
394 2956 mdecorde
  !define /ReDef MULTIUSER_${UNPREFIX}INSTALLMODEPAGE "" ; Unlock strings in the language file(s)
395 728 mdecorde
  !insertmacro MULTIUSER_INSTALLMODEPAGE_INTERFACE
396 728 mdecorde
397 2956 mdecorde
  !define /IfNDef MULTIUSER_INSTALLMODEPAGE_TEXT_TOP "$(MULTIUSER_INNERTEXT_INSTALLMODE_TOP)"
398 2956 mdecorde
  !define /IfNDef MULTIUSER_INSTALLMODEPAGE_TEXT_ALLUSERS "$(MULTIUSER_INNERTEXT_INSTALLMODE_ALLUSERS)"
399 2956 mdecorde
  !define /IfNDef MULTIUSER_INSTALLMODEPAGE_TEXT_CURRENTUSER "$(MULTIUSER_INNERTEXT_INSTALLMODE_CURRENTUSER)"
400 728 mdecorde
401 728 mdecorde
  PageEx custom
402 728 mdecorde
403 2956 mdecorde
    PageCallbacks MultiUser.InstallModePre_${UNIQUEID} MultiUser.InstallModeLeave_${UNIQUEID}
404 728 mdecorde
405 2956 mdecorde
    !define /IfNDef MULTIUSER_INSTALLMODEPAGE_CAPTION " "
406 2956 mdecorde
    Caption "${MULTIUSER_INSTALLMODEPAGE_CAPTION}"
407 728 mdecorde
408 728 mdecorde
  PageExEnd
409 728 mdecorde
410 2956 mdecorde
  !insertmacro MULTIUSER_FUNCTION_INSTALLMODEPAGE MultiUser.InstallModePre_${UNIQUEID} MultiUser.InstallModeLeave_${UNIQUEID}
411 728 mdecorde
412 728 mdecorde
  !undef MULTIUSER_INSTALLMODEPAGE_TEXT_TOP
413 728 mdecorde
  !undef MULTIUSER_INSTALLMODEPAGE_TEXT_ALLUSERS
414 728 mdecorde
  !undef MULTIUSER_INSTALLMODEPAGE_TEXT_CURRENTUSER
415 728 mdecorde
416 728 mdecorde
!macroend
417 728 mdecorde
418 728 mdecorde
!macro MULTIUSER_PAGE_INSTALLMODE
419 728 mdecorde
420 2956 mdecorde
  !verbose push 3
421 728 mdecorde
422 728 mdecorde
  !ifndef MULTIUSER_EXECUTIONLEVEL_ALLUSERS
423 728 mdecorde
    !error "A mixed-mode installation requires MULTIUSER_EXECUTIONLEVEL to be set to Admin, Power or Highest."
424 728 mdecorde
  !endif
425 2956 mdecorde
426 2956 mdecorde
  !ifmacrodef MUI_PAGE_INIT
427 2956 mdecorde
    !insertmacro MUI_PAGE_INIT
428 2956 mdecorde
  !endif
429 2956 mdecorde
  !insertmacro MULTIUSER_PAGEDECLARATION_INSTALLMODE "" ${__COUNTER__}
430 728 mdecorde
431 728 mdecorde
  !verbose pop
432 728 mdecorde
433 728 mdecorde
!macroend
434 728 mdecorde
435 728 mdecorde
!macro MULTIUSER_FUNCTION_INSTALLMODEPAGE PRE LEAVE
436 728 mdecorde
437 2956 mdecorde
  !include nsDialogs.nsh
438 728 mdecorde
439 728 mdecorde
  Function "${PRE}"
440 2956 mdecorde
441 2956 mdecorde
    !if ${MULTIUSER_MINWIN} < 0x500
442 728 mdecorde
    ${ifnot} ${IsNT}
443 728 mdecorde
      Abort
444 728 mdecorde
    ${endif}
445 2956 mdecorde
    !endif
446 2956 mdecorde
447 728 mdecorde
    ${if} $MultiUser.Privileges != "Power"
448 728 mdecorde
      ${andif} $MultiUser.Privileges != "Admin"
449 728 mdecorde
      Abort
450 728 mdecorde
    ${endif}
451 2956 mdecorde
452 2956 mdecorde
    !insertmacro MULTIUSER_PAGE_FUNCTION_CUSTOM PRE
453 2956 mdecorde
    !ifmacrodef MUI_HEADER_TEXT_PAGE
454 2956 mdecorde
      !insertmacro MUI_HEADER_TEXT_PAGE $(MULTIUSER_TEXT_INSTALLMODE_TITLE) $(MULTIUSER_TEXT_INSTALLMODE_SUBTITLE)
455 2956 mdecorde
    !endif
456 2956 mdecorde
457 728 mdecorde
    nsDialogs::Create 1018
458 728 mdecorde
    Pop $MultiUser.InstallModePage
459 728 mdecorde
460 2956 mdecorde
    ${NSD_CreateLabel} 0 2u 100% 42u "${MULTIUSER_INSTALLMODEPAGE_TEXT_TOP}"
461 728 mdecorde
    Pop $MultiUser.InstallModePage.Text
462 728 mdecorde
463 2956 mdecorde
    ${NSD_CreateRadioButton} 15u 50u -15u 10u "${MULTIUSER_INSTALLMODEPAGE_TEXT_ALLUSERS}"
464 728 mdecorde
    Pop $MultiUser.InstallModePage.AllUsers
465 2956 mdecorde
466 2956 mdecorde
    !ifdef MULTIUSER_INSTALLMODEPAGE_SHOWUSERNAME
467 2956 mdecorde
    !ifdef NOSYSTEMCALLS
468 2956 mdecorde
    ReadEnvStr $0 USERNAME
469 2956 mdecorde
    !else
470 2956 mdecorde
    System::Call 'ADVAPI32::GetUserName(t""r0,*i${NSIS_MAX_STRLEN})'
471 2956 mdecorde
    !endif
472 2956 mdecorde
    StrCmp $0 "" +2
473 2956 mdecorde
      StrCpy $0 " ($0)"
474 2956 mdecorde
    ${NSD_CreateRadioButton} 15u 70u -15u 10u "${MULTIUSER_INSTALLMODEPAGE_TEXT_CURRENTUSER}$0"
475 2956 mdecorde
    !else
476 2956 mdecorde
    ${NSD_CreateRadioButton} 15u 70u -15u 10u "${MULTIUSER_INSTALLMODEPAGE_TEXT_CURRENTUSER}"
477 2956 mdecorde
    !endif
478 728 mdecorde
    Pop $MultiUser.InstallModePage.CurrentUser
479 2956 mdecorde
480 728 mdecorde
    ${if} $MultiUser.InstallMode == "AllUsers"
481 728 mdecorde
      SendMessage $MultiUser.InstallModePage.AllUsers ${BM_SETCHECK} ${BST_CHECKED} 0
482 728 mdecorde
    ${else}
483 728 mdecorde
      SendMessage $MultiUser.InstallModePage.CurrentUser ${BM_SETCHECK} ${BST_CHECKED} 0
484 728 mdecorde
    ${endif}
485 728 mdecorde
486 2956 mdecorde
    !insertmacro MULTIUSER_PAGE_FUNCTION_CUSTOM SHOW
487 728 mdecorde
    nsDialogs::Show
488 2956 mdecorde
    !insertmacro MULTIUSER_PAGE_FUNCTION_CUSTOM DESTROYED
489 728 mdecorde
490 728 mdecorde
  FunctionEnd
491 728 mdecorde
492 728 mdecorde
  Function "${LEAVE}"
493 2956 mdecorde
     SendMessage $MultiUser.InstallModePage.AllUsers ${BM_GETCHECK} 0 0 $0
494 728 mdecorde
495 2956 mdecorde
     ${if} $0 = ${BST_CHECKED}
496 728 mdecorde
        Call MultiUser.InstallMode.AllUsers
497 728 mdecorde
     ${else}
498 728 mdecorde
        Call MultiUser.InstallMode.CurrentUser
499 728 mdecorde
     ${endif}
500 728 mdecorde
501 2956 mdecorde
    !insertmacro MULTIUSER_PAGE_FUNCTION_CUSTOM LEAVE
502 728 mdecorde
  FunctionEnd
503 728 mdecorde
504 728 mdecorde
!macroend
505 728 mdecorde
506 728 mdecorde
507 728 mdecorde
!verbose pop
508 728 mdecorde
!endif