UserInfo.nsi 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. Name "UserInfo.dll test"
  2. OutFile UserInfo.exe
  3. !define REALMSG "$\nOriginal non-restricted account type: $2"
  4. Section
  5. ClearErrors
  6. UserInfo::GetName
  7. IfErrors Win9x
  8. Pop $0
  9. UserInfo::GetAccountType
  10. Pop $1
  11. # GetOriginalAccountType will check the tokens of the original user of the
  12. # current thread/process. If the user tokens were elevated or limited for
  13. # this process, GetOriginalAccountType will return the non-restricted
  14. # account type.
  15. # On Vista with UAC, for example, this is not the same value when running
  16. # with `RequestExecutionLevel user`. GetOriginalAccountType will return
  17. # "admin" while GetAccountType will return "user".
  18. UserInfo::GetOriginalAccountType
  19. Pop $2
  20. StrCmp $1 "Admin" 0 +3
  21. MessageBox MB_OK 'User "$0" is in the Administrators group${REALMSG}'
  22. Goto done
  23. StrCmp $1 "Power" 0 +3
  24. MessageBox MB_OK 'User "$0" is in the Power Users group${REALMSG}'
  25. Goto done
  26. StrCmp $1 "User" 0 +3
  27. MessageBox MB_OK 'User "$0" is just a regular user${REALMSG}'
  28. Goto done
  29. StrCmp $1 "Guest" 0 +3
  30. MessageBox MB_OK 'User "$0" is a guest${REALMSG}'
  31. Goto done
  32. MessageBox MB_OK "Unknown error"
  33. Goto done
  34. Win9x:
  35. # This one means you don't need to care about admin or
  36. # not admin because Windows 9x doesn't either
  37. MessageBox MB_OK "Error! This DLL can't run under Windows 9x!"
  38. done:
  39. SectionEnd