How To Get All System Information In VB.NET

Hdisplay system infor

hey everyone so again a vb.net tutorial actually a console application tutorial but you will learn a lot from this things okay now i will tell you what information's you will be getting on the console
  • Your Operating System Full Name
  • Your Operating System Platform
  • Your Operating System Version
  • Your Windows Bit (32,64)
  • Your Computer Name
  • Your Computer Current Language Name
  • Your Computer Current Date And Time
  • Your Computer Manufacturer
  • Your Computer Model
  • Your Operating System Version
  • Your System Type
  • Your Windows Directory
  • Your Number Of Processes 
  • Your Computer Display Information
  • Your Ram Memory
  • Physical Memory
  • Virtual Memory
okay now lets create the program just create a console application and you will see the model 1 now add a class and name it WMI and add this codes into the WMI class

Public Class WMI
    Private objOS As Management.ManagementObjectSearcher
    Private objCS As Management.ManagementObjectSearcher
    Private objMgmt As Management.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 Management.ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem")
        objCS = New Management.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()
        Next
        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()
        Next
    End Sub
    Public ReadOnly Property ComputerName()
        Get
            ComputerName = m_strComputerName
        End Get
    End Property
    Public ReadOnly Property Manufacturer()
        Get
            Manufacturer = m_strManufacturer
        End Get
    End Property
    Public ReadOnly Property Model()
        Get
            Model = m_StrModel
        End Get
    End Property
    Public ReadOnly Property OsName()
        Get
            OsName = m_strOSName
        End Get
    End Property
    Public ReadOnly Property OSVersion()
        Get
            OSVersion = m_strOSVersion
        End Get
    End Property
    Public ReadOnly Property SystemType()
        Get
            SystemType = m_strSystemType
        End Get
    End Property
    Public ReadOnly Property TotalPhysicalMemory()
        Get
            TotalPhysicalMemory = m_strTPM
        End Get
    End Property
    Public ReadOnly Property WindowsDirectory()
        Get
            WindowsDirectory = m_strWindowsDir
        End Get
    End Property
End Class

now add these codes inside the module1

Imports System.Management
Module Module1

    'Author : Mohamed Shimran
    'Blog : http://www.ultimateprogrammingtutorials.blogspot.com

   Dim bit As String
   Dim VGA As String
    Sub Main()
        If My.Computer.Registry.LocalMachine.OpenSubKey("Hardware\Description\System\CentralProcessor\0").GetValue("Identifier").ToString.Contains("x86") Then
            bit = "32-bit"
        Else
            bit = "64-bit"
        End If
        Console.Title = "System Information's"
        Console.WriteLine("your system information's")
        Console.WriteLine("")
        Console.WriteLine(My.Computer.Info.OSFullName.ToString())
        Console.WriteLine(My.Computer.Info.OSPlatform.ToString())
        Console.WriteLine(My.Computer.Info.OSVersion.ToString())
        Console.WriteLine("Windows bit version: " + bit)
        Console.WriteLine("Computer Name: " & My.Computer.Name.ToString())
        Console.WriteLine("Computer Language: " & System.Globalization.CultureInfo.CurrentCulture.DisplayName)
        Console.WriteLine("Current Date/Time: " & Date.Now.ToLongDateString + ", " + Date.Now.ToLongTimeString)
        Console.WriteLine("")
        Dim objWMI As New WMI()
        With objWMI
            Console.WriteLine("Computer Manufacturer = " & .Manufacturer)
            Console.WriteLine("Computer Model = " & .Model)
            Console.WriteLine("OS Version = " & .OSVersion)
            Console.WriteLine("System Type = " & .SystemType)
            Console.WriteLine("Windows Directory = " & .WindowsDirectory)
        End With
        Console.WriteLine("")
        Console.WriteLine("Number of Processes: " & Environment.ProcessorCount.ToString)
        Dim moSearch As New ManagementObjectSearcher("Select * from Win32_Processor")
        Dim moReturn As ManagementObjectCollection = moSearch.Get
        For Each mo As ManagementObject In moReturn
            Console.WriteLine("Processor: " & (mo("name")))
        Next
        Dim ramsize As Integer
        ramsize = My.Computer.Info.TotalPhysicalMemory / 1024 / 1024
        Console.WriteLine("Memory: " & ramsize.ToString & "MB RAM")
        Console.WriteLine("")
        Dim WmiSelect As New ManagementObjectSearcher _
        ("root\CIMV2", "SELECT * FROM Win32_VideoController")
        For Each WmiResults As ManagementObject In WmiSelect.Get()
            VGA = WmiResults.GetPropertyValue("Name").ToString
        Next
        Console.WriteLine("Computer Display Info: " & VGA)
        Dim intX As Integer = Windows.Forms.Screen.PrimaryScreen.Bounds.Width
        Dim intY As Integer = Windows.Forms.Screen.PrimaryScreen.Bounds.Height
        Console.WriteLine("Screen Resolution: " & intX & " X " & intY)
        Console.WriteLine("")
        Console.WriteLine("Total Physical Memory: " & My.Computer.Info.TotalPhysicalMemory.ToString())
        Console.WriteLine("Total Virtual Memory: " & My.Computer.Info.TotalVirtualMemory.ToString())
        Console.WriteLine("Available Virtual Memory: " & My.Computer.Info.AvailableVirtualMemory.ToString())
        Console.WriteLine("Available Physical Memory: " & My.Computer.Info.AvailablePhysicalMemory.ToString())
        Console.WriteLine("Network Available: " & My.Computer.Network.IsAvailable.ToString())
        Console.WriteLine("")
        Console.WriteLine("")
        Console.WriteLine("Additional Info:")
        Console.WriteLine("Scroll Lock " & My.Computer.Keyboard.ScrollLock)
        Console.WriteLine("Num Lock " & My.Computer.Keyboard.NumLock)
        Console.WriteLine("Caps Lock " & My.Computer.Keyboard.CapsLock)
        Console.WriteLine("")
        Console.WriteLine("Current Processes: ")
        Console.WriteLine("")
        For Each p As Process In Process.GetProcesses
            Console.WriteLine(p)
        Next
        Console.ReadKey()
    End Sub
End Module

now just debug and see how it works :)

 I forgot to mention that you have to add System.Drawing, System.Windows, System.Management from reference and you have to add these namespaces
Imports System.Management
Imports System.Drawing
Imports System.Windows
Imports System.Windows.Forms
By the way I would like to thank the commenter who said about this.

10 comments

You have to add three references:
-> System.Management
-> System.Windows
-> System.Drawing
And then import those namespace (I aint sure if that it's the name for them).
At least I had to. Everything worked fine!

Reply

Thanks you so much for letting me know :)

Reply

what if i need to but text box = java version
pls send to me in my mail
alazhary.ahmed@gmail.com

Reply

Why this long procedure
Maybe display information in msgbox

imports system
imports microsoft.win32 //Not even necesary

Public Class Form1

private sub form1_load()
msgbox("Operting System: " & My.Computer.Info.OSFullName & vbNewLine & " UserName: " & My.User.Name & vbNewLine & " HostName: " & strHostName & vbNewLine & " IPAddress: " & strIPAddress )
//You can add as much as you want
end sub

End Class

Thanks
Knowledge is free

Reply

naaahhh i have a error 'span' is not declared. It may be inaccessible due to its protection level. and this '>'
expected.

Reply

that span is a HTML tag, it sometimes comes into the code. I don't know why ! still you delete the span and it will work :)

Reply

I loved the way you discuss the topic great work thanks for the share Your informative post.
HBR Cases Solution

Reply

Self-expression is a part of our consciousness, its direct manifestation!
tutuapp free
tutuapp vip

Reply

Post a Comment

Note: Only a member of this blog may post a comment.