User Account Information using WMI

Using the Win32_UserAccount WMI class we can iterate through the user account information on a local computer.

From MSDN:

The Win32_UserAccount WMI class contains information about a user account on a computer system running Windows.

Sample usage

The following function will query the Win32_UserAccount class and iterate through it to list all available properties.

Function GetUserAccountInfo()

Dim objWMI As Object
Dim accounts As Object
Dim account As Object

Set objWMI = GetWMIService

  Set accounts = objWMI.ExecQuery("Select * from Win32_UserAccount")

For Each account In accounts
  Debug.Print account.AccountType
  Debug.Print account.Caption
  Debug.Print account.Description
  Debug.Print account.Disabled
  Debug.Print account.Domain
  Debug.Print account.FullName
  Debug.Print account.InstallDate
  Debug.Print account.LocalAccount
  Debug.Print account.Lockout
  Debug.Print account.Name
  Debug.Print account.PasswordChangeable
  Debug.Print account.PasswordExpires
  Debug.Print account.PasswordRequired
  Debug.Print account.SID
  Debug.Print account.SIDType
  Debug.Print account.Status
Next account

End Function

Function GetWMIService() As Object
' http://msdn.microsoft.com/en-us/library/aa394586(VS.85).aspx
Dim strComputer As String

  strComputer = "."

  Set GetWMIService = GetObject("winmgmts:" _
                              & "{impersonationLevel=impersonate}!\\" _
                              & strComputer & "\root\cimv2")
End Function

Site last updated: May 17, 2012

Peltier Tech Chart Utilities for Excel Peltier Tech Waterfall Chart Utility Peltier Tech Box and Whisker Chart Utility Peltier Tech Cluster-Stack Chart Utility Peltier Tech Panel Chart Utility Peltier Tech Marimekko Chart Utility Peltier Tech Dot Plot Utility Peltier Tech Cascade Chart Utility