Operating system information is accessible using the WMI class Win32_OperatingSystem. This class can tell us what operating system is present on a local computer, as well as time zone and the directory where Windows is installed.
From MSDN:
The Win32_OperatingSystem WMI class represents a Windows-based operating system installed on a computer. Any operating system that can be installed on a computer that can run a Windows-based operating system is a descendent or member of this class.
Several of the properties are not accessible by Windows XP so they are commented out in the code below.
Sample usage
Function GetOSInfo()
Dim objWMI As Object
Dim OSs As Object
Dim OS As Object
Set objWMI = GetWMIService
Set OSs = objWMI.ExecQuery("Select * from Win32_OperatingSystem")
For Each OS In OSs
Debug.Print OS.BootDevice
Debug.Print OS.BuildNumber
Debug.Print OS.BuildType
Debug.Print OS.Caption
Debug.Print OS.CodeSet
Debug.Print OS.CountryCode
Debug.Print OS.CreationClassName
Debug.Print OS.CSCreationClassName
Debug.Print OS.CSDVersion
Debug.Print OS.CSName
Debug.Print OS.CurrentTimeZone
Debug.Print OS.DataExecutionPrevention_Available
Debug.Print OS.DataExecutionPrevention_32BitApplications
Debug.Print OS.DataExecutionPrevention_Drivers
Debug.Print OS.DataExecutionPrevention_SupportPolicy
Debug.Print OS.Debug
Debug.Print OS.Description
Debug.Print OS.Distributed
Debug.Print OS.EncryptionLevel
Debug.Print OS.ForegroundApplicationBoost
Debug.Print OS.FreePhysicalMemory
Debug.Print OS.FreeSpaceInPagingFiles
Debug.Print OS.FreeVirtualMemory
Debug.Print OS.InstallDate
Debug.Print OS.LargeSystemCache
Debug.Print OS.LastBootUpTime
Debug.Print OS.LocalDateTime
Debug.Print OS.Locale
Debug.Print OS.Manufacturer
Debug.Print OS.MaxNumberOfProcesses
Debug.Print OS.MaxProcessMemorySize
'Debug.Print OS.MUILanguages ' not supported by Windows XP
Debug.Print OS.Name
Debug.Print OS.NumberOfLicensedUsers
Debug.Print OS.NumberOfProcesses
Debug.Print OS.NumberOfUsers
'Debug.Print OS.OperatingSystemSKU ' not supported by Windows XP
Debug.Print OS.Organization
'Debug.Print OS.OSArchitecture ' not supported by Windows XP
Debug.Print OS.OSLanguage
Debug.Print OS.OSProductSuite
Debug.Print OS.OSType
Debug.Print OS.OtherTypeDescription
'Debug.Print OS.PAEEnabled ' not supported by Windows XP
Debug.Print OS.PlusProductID
Debug.Print OS.PlusVersionNumber
Debug.Print OS.Primary
Debug.Print OS.ProductType
Debug.Print OS.RegisteredUser
Debug.Print OS.SerialNumber
Debug.Print OS.ServicePackMajorVersion
Debug.Print OS.ServicePackMinorVersion
Debug.Print OS.SizeStoredInPagingFiles
Debug.Print OS.Status
Debug.Print OS.SuiteMask
Debug.Print OS.SystemDevice
Debug.Print OS.SystemDirectory
Debug.Print OS.SystemDrive
Debug.Print OS.TotalSwapSpaceSize
Debug.Print OS.TotalVirtualMemorySize
Debug.Print OS.TotalVisibleMemorySize
Debug.Print OS.Version
Debug.Print OS.WindowsDirectory
Next OS
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
