Skip to content

Instantly share code, notes, and snippets.

@okieselbach
Created December 15, 2018 11:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save okieselbach/3a4fcfa532bb5a3c328e9a15395db320 to your computer and use it in GitHub Desktop.
Save okieselbach/3a4fcfa532bb5a3c328e9a15395db320 to your computer and use it in GitHub Desktop.
Dim WshShell, colItems, objItem, objGroup, objUser
Dim strUser, strAdministratorsGroup, bAdmin
bAdmin = False
On Error Resume Next
Set WshShell = CreateObject("WScript.Shell")
strUser = WshShell.ExpandEnvironmentStrings("%Username%")
winmgt = "winmgmts:{impersonationLevel=impersonate}!//"
Set colItems = GetObject(winmgt).ExecQuery("Select Name from Win32_Group where SID='S-1-5-32-544'",,48)
For Each objItem in colItems
strAdministratorsGroup = objItem.Name
Next
Set objGroup = GetObject("WinNT://./" & strAdministratorsGroup)
For Each objUser in objGroup.Members
If objUser.Name = strUser Then
bAdmin = True
Exit For
End If
Next
On Error Goto 0
If bAdmin Then
Echo "Admin"
Else
Echo "User"
End If
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment