Or the output of this last attempt before I give up as incompetent. We need to figure out what, exactly, your Caption value contains.
[code]set objWMIService = GetObject("winmgmts:\\.\root\cimv2") set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem",,32) for each objItem in colItems wscript.echo "Caption: " & StringToAscii(objItem.Caption) wscript.echo "Family: " & os_family(objItem.Caption, vbBinaryCompare) next
function os_family(os,comp) if InStr(1, os, " 95", comp) then os_family="Windows 95" if InStr(1, os, " 98", comp) then os_family="Windows 98" if InStr(1, os, " NT", comp) then os_family="Windows NT" if InStr(1, os, "2000", comp) then os_family="Windows 2000" if InStr(1, os, " XP", comp) then os_family="Windows XP" if InStr(1, os, "2003", comp) then os_family="Windows 2003" if InStr(1, os, "Vista", comp) then os_family="Windows Vista" if InStr(1, os, "2008", comp) then os_family="Windows 2008" if InStr(1, os, "7", comp) then os_family="Windows 7" if InStr(1, os, "8", comp) then os_family="Windows 8" end function
Function StringToAscii(str) Dim result, x StringToAscii = "" If Len(str)=0 Then Exit Function If Len(str)=1 Then result = Asc(Mid(str, 1, 1)) StringToAscii = Left("000", 3-Len(CStr(result))) & CStr(result) Exit Function End If result = "" For x=1 To Len(str) result = result & StringToAscii(Mid(str, x, 1)) Next StringToAscii = result End Function[/code]
|