My first attempt is to query Win32_OperatingSystem for the caption, and test whether the caption "equals" the operating system I am testing for:
Dim objWMIService, strComputer
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
msgbox getOperatingSystemCaption()
msgbox meetsOperatingSystemRequirement()
Function getOperatingSystemCaption()
Dim strCaption, colOperatingSystems, objOperatingSystem
Set colOperatingSystems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
strCaption = objOperatingSystem.Caption
Exit For
Next
getOperatingSystemCaption = strCaption
End Function
Function meetsOperatingSystemRequirement()
meetsOperatingSystemRequirement = False
If getOperatingSystemCaption() = "Microsoft Windows 7 Home Premium" Then
meetsOperatingSystemRequirement = True
End If
End Function
I suppose I can use InStr, however I still do not understand why the "Caption" and my string are not equal.