2010-05-15 13:13:55 +00:00
|
|
|
|
2010-05-14 18:15:27 +00:00
|
|
|
Function IsUserAdmin
|
2010-05-15 13:13:55 +00:00
|
|
|
|
2010-05-14 18:15:27 +00:00
|
|
|
ClearErrors
|
|
|
|
UserInfo::GetName
|
|
|
|
IfErrors Win9x
|
2010-05-15 13:13:55 +00:00
|
|
|
|
|
|
|
Pop $0
|
2010-05-14 18:15:27 +00:00
|
|
|
UserInfo::GetAccountType
|
2010-05-15 13:13:55 +00:00
|
|
|
Pop $1
|
2010-05-14 18:15:27 +00:00
|
|
|
|
2010-05-15 13:13:55 +00:00
|
|
|
# GetOriginalAccountType will check the tokens of the original user of the
|
|
|
|
# current thread/process. If the user tokens were elevated or limited for
|
|
|
|
# this process, GetOriginalAccountType will return the non-restricted
|
|
|
|
# account type.
|
|
|
|
# On Vista with UAC, for example, this is not the same value when running
|
|
|
|
# with `RequestExecutionLevel user`. GetOriginalAccountType will return
|
|
|
|
# "admin" while GetAccountType will return "user".
|
|
|
|
UserInfo::GetOriginalAccountType
|
|
|
|
Pop $2
|
|
|
|
|
|
|
|
; Windows9x can sometimes return empty strings...
|
|
|
|
StrCmp $1 "" 0 +2
|
|
|
|
Goto Win9x
|
|
|
|
|
|
|
|
StrCmp $1 "Admin" 0 +3
|
|
|
|
DetailPrint '(UAC) User "$0" is in the Administrators group'
|
|
|
|
Goto done
|
|
|
|
|
|
|
|
StrCmp $1 "Power" 0 +3
|
|
|
|
DetailPrint '(UAC) User "$0" is in the Power Users group'
|
|
|
|
Goto done
|
|
|
|
|
|
|
|
StrCmp $1 "User" 0 +3
|
|
|
|
DetailPrint '(UAC) User "$0" is just a regular user'
|
|
|
|
Goto done
|
|
|
|
|
|
|
|
StrCmp $1 "Guest" 0 +3
|
|
|
|
; Guest account? Probably doomed to failure, but might as well try, just in case some shit
|
|
|
|
; is being mis-reported.
|
|
|
|
DetailPrint '(UAC) User "$0" is a guest -- this installer is probably going to fail. Good luck.'
|
|
|
|
Goto done
|
|
|
|
|
|
|
|
;MessageBox MB_OK "Unknown error while trying to detect "
|
|
|
|
DetailPrint "(UAC) Unknown error while trying to detect account type; assuming USER mode."
|
|
|
|
StrCpy $1 "User"
|
|
|
|
Goto done
|
|
|
|
|
|
|
|
Win9x:
|
|
|
|
# This one means you don't need to care about admin or
|
|
|
|
# not admin because Windows 9x doesn't either
|
|
|
|
MessageBox MB_OK "Error! PCSX2 requires Windows 2000 or newer to install and run!"
|
|
|
|
Quit
|
|
|
|
|
|
|
|
done:
|
|
|
|
|
|
|
|
; How to return the admin modeas a variable? NSIS confuses me -- air
|
|
|
|
;Exch $R0
|
2010-05-14 18:15:27 +00:00
|
|
|
|
|
|
|
FunctionEnd
|