home *** CD-ROM | disk | FTP | other *** search
/ Hackers Magazine 57 / CdHackersMagazineNr57.iso / Software / Programming / nsis-2.46-setup.exe / Examples / UserInfo / UserInfo.nsi
Text File  |  2007-12-01  |  1KB  |  45 lines

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