Click here to Skip to main content
13,055,490 members (48,014 online)
Click here to Skip to main content
Add your own
alternative version


2 bookmarked
Posted 17 Apr 2011

Getting Hardware and Software Details of the Computers in your Domain

, 17 Apr 2011
Rate this:
Please Sign up or sign in to vote.
How to get hardware and software details of the computers in your domain

Win32 classes can be used as shown in the simple example below to get the hardware and software specs of a computer:

Private Sub GetOperatingSystemDetails()
    Dim mos As ManagementObjectSearcher = _
        New ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem")

    For Each mo As ManagementObject In mos.Get
        Dim OsName As String = mo("name")
        Dim Version As String = mo("version") 
        Dim SerialNumber As String = mo("serialNumber") 
End Sub

In the above example, we only used one of the Win32 classes (Win32_OpratingSystem) and for that, we only read three properties out of more than 60.

To use this example code, you need to add a reference to System.Management in your project and import that.

In a previous post, A VB.NET program to list all computers in your domain, I showed how you can get the list of computers in your domain. You can combine traversing through computers in your domain as shown in that post with the use of Win32 classes to get the details of those computers. To run Win32 related commands on remote computers, you need to have the required privilege. In addition to that, those computers also need to have RPC and WMI services running on them.

The following example shows how to read the above three values we had for the first example from another computer in your domain:

Public Sub GetOperatingSystemDetails (ByVal computer As String)
    Dim options As ConnectionOptions = New ConnectionOptions()
    options.Username = "USERNAME" ' Select User Name
    options.Password = "PASSWORD" ' Select password
    ' You can also specify Kerberos instead of ntlm below
    options.Authority = "ntlmdomain:Domain" ' Select Domain

    Dim scope As ManagementScope = _
        New ManagementScope("\\" & computer & "\root\cimv2", options)


    Dim query As ObjectQuery = _
        New ObjectQuery("SELECT * FROM Win32_OperatingSystem")
    Dim mos As ManagementObjectSearcher = _
        New ManagementObjectSearcher(scope, query)
    Dim queryCollection As ManagementObjectCollection = mos.Get

    For Each mo As ManagementObject In queryCollection
        Dim OsName As String = mo("name")
        Dim Version As String = mo("version")
        Dim SerialNumber As String = mo("serialNumber")
End Sub


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Morris Bahrami
Australia Australia
I have over 17 years of experience in software development in a variety of fields. For last 7 years the emphasis has been mostly on .NET technology (C# and VB.NET) which includes WPF, WCF and ASP.NET AJAX. Also have SQL Server experience including SSIS and SSRS. My blog ( has a collection of tips and general info for Microsoft Developers.

You may also be interested in...


Comments and Discussions

General5 Pin
Lloyd Atkinson17-Apr-11 11:49
memberLloyd Atkinson17-Apr-11 11:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170713.1 | Last Updated 17 Apr 2011
Article Copyright 2011 by Morris Bahrami
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid