| 1 |
Name "UserInfo.dll test" |
| 2 |
OutFile UserInfo.exe |
| 3 |
RequestExecutionLevel Highest |
| 4 |
|
| 5 |
!define REALMSG "$\nOriginal non-restricted account type: $2" |
| 6 |
|
| 7 |
Section |
| 8 |
ClearErrors |
| 9 |
UserInfo::GetName |
| 10 |
IfErrors PluginFail |
| 11 |
Pop $0 |
| 12 |
StrCmp $0 "" 0 +2 ; GetName can return a empty string on Win9x |
| 13 |
StrCpy $0 "?" |
| 14 |
UserInfo::GetAccountType |
| 15 |
Pop $1 |
| 16 |
# GetOriginalAccountType will check the tokens of the original user of the |
| 17 |
# current thread/process. If the user tokens were elevated or limited for |
| 18 |
# this process, GetOriginalAccountType will return the non-restricted |
| 19 |
# account type. |
| 20 |
# On Vista with UAC, for example, this is not the same value when running |
| 21 |
# with `RequestExecutionLevel user`. GetOriginalAccountType will return |
| 22 |
# "admin" while GetAccountType will return "user". |
| 23 |
UserInfo::GetOriginalAccountType |
| 24 |
Pop $2 |
| 25 |
StrCmp $1 "Admin" 0 +3 ; Note: Win9x always returns "Admin" |
| 26 |
MessageBox MB_OK 'User "$0" is in the Administrators group${REALMSG}' |
| 27 |
Goto done |
| 28 |
StrCmp $1 "Power" 0 +3 |
| 29 |
MessageBox MB_OK 'User "$0" is in the Power Users group${REALMSG}' |
| 30 |
Goto done |
| 31 |
StrCmp $1 "User" 0 +3 |
| 32 |
MessageBox MB_OK 'User "$0" is just a regular user${REALMSG}' |
| 33 |
Goto done |
| 34 |
StrCmp $1 "Guest" 0 +3 |
| 35 |
MessageBox MB_OK 'User "$0" is a guest${REALMSG}' |
| 36 |
Goto done |
| 37 |
MessageBox MB_OK "Unknown error" |
| 38 |
Goto done |
| 39 |
|
| 40 |
PluginFail: |
| 41 |
MessageBox MB_OK "Error! Unable to call plug-in!" |
| 42 |
|
| 43 |
done: |
| 44 |
SectionEnd |
| 45 |
|