1 |
|
2 |
Function IsUserAdmin |
3 |
|
4 |
ClearErrors |
5 |
UserInfo::GetName |
6 |
IfErrors Win9x |
7 |
|
8 |
Pop $0 |
9 |
UserInfo::GetAccountType |
10 |
Pop $1 |
11 |
|
12 |
# GetOriginalAccountType will check the tokens of the original user of the |
13 |
# current thread/process. If the user tokens were elevated or limited for |
14 |
# this process, GetOriginalAccountType will return the non-restricted |
15 |
# account type. |
16 |
# On Vista with UAC, for example, this is not the same value when running |
17 |
# with `RequestExecutionLevel user`. GetOriginalAccountType will return |
18 |
# "admin" while GetAccountType will return "user". |
19 |
UserInfo::GetOriginalAccountType |
20 |
Pop $2 |
21 |
|
22 |
; Windows9x can sometimes return empty strings... |
23 |
StrCmp $1 "" 0 +2 |
24 |
Goto Win9x |
25 |
|
26 |
StrCmp $1 "Admin" 0 +3 |
27 |
DetailPrint '(UAC) User "$0" is in the Administrators group' |
28 |
Goto done |
29 |
|
30 |
StrCmp $1 "Power" 0 +3 |
31 |
DetailPrint '(UAC) User "$0" is in the Power Users group' |
32 |
Goto done |
33 |
|
34 |
StrCmp $1 "User" 0 +3 |
35 |
DetailPrint '(UAC) User "$0" is just a regular user' |
36 |
Goto done |
37 |
|
38 |
StrCmp $1 "Guest" 0 +3 |
39 |
; Guest account? Probably doomed to failure, but might as well try, just in case some shit |
40 |
; is being mis-reported. |
41 |
DetailPrint '(UAC) User "$0" is a guest -- this installer is probably going to fail. Good luck.' |
42 |
Goto done |
43 |
|
44 |
;MessageBox MB_OK "Unknown error while trying to detect " |
45 |
DetailPrint "(UAC) Unknown error while trying to detect account type; assuming USER mode." |
46 |
StrCpy $1 "User" |
47 |
Goto done |
48 |
|
49 |
Win9x: |
50 |
# This one means you don't need to care about admin or |
51 |
# not admin because Windows 9x doesn't either |
52 |
MessageBox MB_OK "Error! PCSX2 requires Windows 2000 or newer to install and run!" |
53 |
Quit |
54 |
|
55 |
done: |
56 |
|
57 |
; How to return the admin modeas a variable? NSIS confuses me -- air |
58 |
;Exch $R0 |
59 |
|
60 |
FunctionEnd |