WMI or Windows Management Instrumentation information provides you the information of CPU, Motherboard and BIOS of your Windows machine. If you don’t know about WMI, read how to find CPU and BIOS information using WMIC.

If you’re a Computer programmer and looking for some resource to get WMI information in VB.NET, this post is going to help you with that. Use the below given VB.NET program code to get WMI information:

VB.NET class to get WMI Information

Public Class clsWMI
    Private objOS As ManagementObjectSearcher
    Private objCS As ManagementObjectSearcher
    Private objMgmt As ManagementObject
    Private m_strComputerName As String
    Private m_strManufacturer As String
    Private m_StrModel As String
    Private m_strOSName As String
    Private m_strOSVersion As String
    Private m_strSystemType As String
    Private m_strTPM As String
    Private m_strWindowsDir As String

    Public Sub New()

        objOS = New ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem")
        objCS = New ManagementObjectSearcher("SELECT * FROM Win32_ComputerSystem")
        For Each objMgmt In objOS.Get
            m_strOSName = objMgmt("name").ToString()
            m_strOSVersion = objMgmt("version").ToString()
            m_strComputerName = objMgmt("csname").ToString()
            m_strWindowsDir = objMgmt("windowsdirectory").ToString()

        For Each objMgmt In objCS.Get
            m_strManufacturer = objMgmt("manufacturer").ToString()
            m_StrModel = objMgmt("model").ToString()
            m_strSystemType = objMgmt("systemtype").ToString
            m_strTPM = objMgmt("totalphysicalmemory").ToString()
    End Sub

    Public ReadOnly Property ComputerName()
            ComputerName = m_strComputerName
        End Get

    End Property
    Public ReadOnly Property Manufacturer()
            Manufacturer = m_strManufacturer
        End Get

    End Property
    Public ReadOnly Property Model()
            Model = m_StrModel
        End Get

    End Property
    Public ReadOnly Property OsName()
            OsName = m_strOSName
        End Get

    End Property

    Public ReadOnly Property OSVersion()
            OSVersion = m_strOSVersion
        End Get

    End Property
    Public ReadOnly Property SystemType()
            SystemType = m_strSystemType
        End Get

    End Property
    Public ReadOnly Property TotalPhysicalMemory()
            TotalPhysicalMemory = m_strTPM
        End Get

    End Property

    Public ReadOnly Property WindowsDirectory()
            WindowsDirectory = m_strWindowsDir
        End Get

    End Property

End Class


To use the above VB.NET class, you must add a reference to System.Management from the Project | References menu.

Imports System.Management

Using the class

The sample code explains how to use the above mentioned class:

Dim objWMI As New clsWMI()
With objWMI
      Debug.WriteLine("Computer Name = " & .ComputerName)
      Debug.WriteLine("Computer Manufacturer = " & .Manufacturer)
      Debug.WriteLine("Computer Model = " & .Model)
      Debug.WriteLine("OS Name = " & .OsName)
      Debug.WriteLine("OS Version = " & .OSVersion)
      Debug.WriteLine("System Type = " & .SystemType)
      Debug.WriteLine("Total Physical Memory = " & .TotalPhysicalMemory)
      Debug.WriteLine("Windows Directory = " & .WindowsDirectory)
End With

Hope you find this article useful. Code courtesy: FreeVBCode.