Forum Discussion
TanyaYatskovska
Alumni
12 years agoHi Bobby,
Here is the sample script adapted to TestComplete:
Sub GetAllUsers
Dim wmiService, computerName, objectsList, user
computerName = "."
Set wmiService = GetObject("winmgmts:"&"{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objectsList = wmiService.ExecQuery ("Select * from Win32_UserAccount Where LocalAccount = True")
For Each object in objectsList
user = "Account Type: " & object.AccountType & vbCrLf &_
"Caption: " & object.Caption & vbCrLf &_
"Full Name: " & object.FullName
Call Log.Message("UserInfo", user)
Next
End Sub
Please make sure that all the needed WMI settings are set on your computer according to the "Working With WMI Objects in Scripts" article.
Here is the sample script adapted to TestComplete:
Sub GetAllUsers
Dim wmiService, computerName, objectsList, user
computerName = "."
Set wmiService = GetObject("winmgmts:"&"{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objectsList = wmiService.ExecQuery ("Select * from Win32_UserAccount Where LocalAccount = True")
For Each object in objectsList
user = "Account Type: " & object.AccountType & vbCrLf &_
"Caption: " & object.Caption & vbCrLf &_
"Full Name: " & object.FullName
Call Log.Message("UserInfo", user)
Next
End Sub
Please make sure that all the needed WMI settings are set on your computer according to the "Working With WMI Objects in Scripts" article.