I am trying to get all the group users in a computer. If I do this manually, my way is to go to Computer Management to get the list of Local Users and Group, and from there, I can get the list of Users and Group.
This is my code and I use AutoIt:
Func User()
Local $objWMIService, $colSettings, $objComputer, $strComputer = "."
;# Initiate the object
$objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2")
;# Check if it's an object
If IsObj($objWMIService) Then
;# Search for PC Infomration
$colSettings = $objWMIService.ExecQuery("Select * from Win32_GroupUser")
If IsObj($colSettings) Then
For $objComputer In $colSettings
If $objComputer.AccountType <> '' Then
Return MsgBox(0, "RETURN", "AccountType: " & $objComputer.AccountType & @CRLF & "Full Name: " & $objComputer.FullName & @CRLF & "Caption: " & $objComputer.Caption & @CRLF & "Name: " & $objComputer.Name)
EndIf
Next
Else
MsgBox(0, "RETURN", $colSettings & " IS NOT AN OBJ")
EndIf
Else
MsgBox(0, "RETURN", $objWMIService & " IS NOT AN OBJ")
EndIf
EndFunc ;==>User
However, no output is being returned. Is my query correct at all?