Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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
Set objGroup = GetObject("WinNT://./" & strAdministratorsGroup)
For Each objUser in objGroup.Members
If objUser.Name = strUser Then
bAdmin = True
Exit For
End If
On Error Goto 0
If bAdmin Then
Echo "Admin"
Echo "User"
End If
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment