私の最初の試みは、Win32_OperatingSystem にキャプションを照会し、キャプションがテスト対象のオペレーティング システムと "等しい" かどうかをテストすることです。
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
InStr を使用できると思いますが、「キャプション」と文字列が等しくない理由はまだわかりません。