Share via


Find Operating System Information from your VB.NET 2005 application

In VS 2005, it has become really easy to find the Operating System's information using some of the classes. Let's take a look at how do we do it in VB 2005...

    Sub DisplayOperatingSystemInformation()
Dim osInfo As OperatingSystem
osInfo = Environment.OSVersion
Dim verInfo As Version
verInfo = osInfo.Version
'Display Version Information
MessageBox.Show( _
"Major Version = " & verInfo.Major & vbCrLf & _
"Minor Version = " & verInfo.Minor & vbCrLf & _
"Revision = " & verInfo.Revision & vbCrLf & _
"Build = " & verInfo.Build & vbCrLf & _
"Platform = " & osInfo.Platform & vbCrLf & _
"Platform String = " & osInfo.VersionString, _
"Operating System Information", MessageBoxButtons.OK, _
MessageBoxIcon.Information)
End Sub

Here is the output of this Method...

Cheers
-Rahul Soni

OSI.GIF

Comments

  • Anonymous
    January 04, 2007
    concise and very helpful thanks!

  • Anonymous
    March 05, 2007
    Hi, I need to know if the OS on a machine if Windows Server or not. PlatForm property always returnd WinNT for Win XP or Server. How would you distinguish between them? Please reply to me at nilesh.leuva@bmwgroup.ca Thanks Nilesh

  • Anonymous
    March 06, 2007
    The comment has been removed

  • Anonymous
    March 07, 2007
    Thanks for the info. However, i found somehting else that was much accurate, user friendly and helpful.


Imports System.Management Public Class ClientInfo    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()        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

  • Anonymous
    March 07, 2007
    Wow, many thanks for sharing that Nilesh! I tested it and it works just fine :o) Regards, Rahul

  • Anonymous
    March 07, 2007
    I blogged about how to find Operating System Information from your VB.NET 2005 application last year

  • Anonymous
    March 16, 2007
    Any idea how to make it determine which edition of Windows Vista is running? (ie: Home Basic, Home Premium, Business, Ultimate)

  • Anonymous
    March 17, 2007
    Hi That Guy :) I believe the code Nilesh provided should work. I haven't tried it though since I don't have any other OS to test on! Check this out... http://blogs.msdn.com/rahulso/archive/2007/03/07/using-system-management-to-get-information-about-the-operating-system-from-your-vb-net-application.aspx Rahul

  • Anonymous
    June 10, 2008
    Hi That works very well. My problem is how to find info for the workstation under ASP.Net such as :- OS Info Network card Thank you Jay

  • Anonymous
    October 19, 2008
    hi, i have to make a term project in VC++ 6.0 a .exe type which when executed in ones computer gives all the information about the system(i have to include as many as possible). Can any one help me out which class and functions should i use ?  

  • Anonymous
    November 17, 2008
    Hi mr.Nilesh,  iam getting error when using your program, "Namespace or type specified in the Imports 'System.management' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases." maybe a minor mistake in my installation?

  • Anonymous
    June 12, 2009
    need some help with code for searching for a record in a ms access database using vb.net 2005,