VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



WMI sample: list users and/or groups on a domain or on a computer.

by Anonymous (267 Submissions)
Category: Internet/HTML
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Sun 4th May 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)

WMI sample: list users and/or groups on a domain or on a computer.

Rate WMI sample: list users and/or groups on a domain or on a computer.



' This function lists all accounts on a computer or domain

' Goto http://www.activxperts.com/activmonitor and click on WMI for more samples


Sub ListAccounts( strComputer )
    Dim objWMIService, colItems

Set objWMIService = GetObject( "winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Account",,48)
For Each objItem in colItems
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Domain: " & objItem.Domain
    Wscript.Echo "InstallDate: " & objItem.InstallDate
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "SID: " & objItem.SID
    Wscript.Echo "SIDType: " & objItem.SIDType
Wscript.Echo "Status: " & objItem.Status
Next
End Sub



' Main

Dim strComputer
Do
   strComputer = inputbox( "Please enter a computername or . for local computer", "Input" )
Loop until strComputer <> ""

ListAccounts( strComputer )

WScript.Echo( "For more samples, goto http://www.activxperts.com/activmonitor and click" )
WScript.Echo( "on WMI" )

Download this snippet    Add to My Saved Code

WMI sample: list users and/or groups on a domain or on a computer. Comments

No comments have been posted about WMI sample: list users and/or groups on a domain or on a computer.. Why not be the first to post a comment about WMI sample: list users and/or groups on a domain or on a computer..

Post your comment

Subject:
Message:
0/1000 characters