If you looking to find a computer or server’s OS type using VBScript, you can use my ready to use function as below.
‘///////////////////////////////////////
‘ Function: FindOSType
‘ Parameter: Computer Name
‘ Purpose: This function return the OS name of the provided computer for all
‘ Windows OS machines
‘
‘ Written by: Anand Venkatachalapathy (http://anandpv.spaces.live.com)
‘///////////////////////////////////////
Function FindOSType(ComputerName)
‘Defining Variables
Dim objWMI, objItem, colItems
Dim OSVersion, OSName, ProductType
‘Get the WMI object and query results
Set objWMI = GetObject("winmgmts:\" & ComputerName & "rootcimv2")
Set colItems = objWMI.ExecQuery("Select * from Win32_OperatingSystem",,48)
‘Get the OS version number (first two) and OS product type (server or desktop)
For Each objItem in colItems
OSVersion = Left(objItem.Version,3)
ProductType = objItem.ProductType
Next
‘Time to convert numbers into names
Select Case OSVersion
Case "6.0"
OSName = "Windows Vista"
Case "5.2"
OSName = "Windows 2003"
Case "5.1"
OSName = "Windows XP"
Case "5.0"
OSName = "Windows 2000"
Case "4.0"
OSName = "Oh! Really! NT 4.0"
Case Else
OSName = "Hi! Grandpa! Windows ME or older"
End Select
‘Return the OS name
FindOSType = OSName
‘Clear the memory
Set colItems = Nothing
Set objWMI = Nothing
End Function
Then what is version for Windows7
6.1
Windows 7 and Windows Server 2008 R2 both use 6.1 – you need to break down the .Caption value at that point to determine which is which (same as with Vista and Server 2008 both using 6.0). This script needs to be updated to remain useful.
This function should be renamed to GetWindowsVersion. I arrived at this site looking for a FindOSType function (Windows, Linux, OS X, etc) but instead find yet another Windows version script. Poor choice for the function name.