How can I test whether or not "Microsoft Windows 7 Home Premium" is the operating system using VBScript? -
My first attempt is to query Win32_OperatingSystem for captions, and check that I do test for caption "equal" operating system I am or not:
Moderate objWMIService, strComputer strComputer = "." ObjWMIService = GetObject ("winmgmts: \\" & amp; str computer and amp; \ "\ root \ CIMV2") msgbox getOperatingSystemCaption () msgbox getRescriptionCustomguagment () function getOperatingSystemCaption () Dim strCaption, colOperatingSystems, objOperatingSystem set colOperatingSystems = objWMIService ExecQuery _ ("Choose * from Win32_OperatingSystem *) for every objOperating system colOperatingSystems strCaption = objOperatingSystem.Caption exit Next getOperatingSystemCaption = strCaptionException function for functionApparation SystemRegistration () is foundOpering SystemRegistration = FalseOperatingSystemRequirement = False if getOperatingSystemCaption () = "Microsoft Windows 7 Home Premium" then getRescribed SystemRecipement = True End if End Function
I think I can use InStr, although I still do not understand That's why "caption" and my strings are not identical.
Are you sure that "Microsoft Windows XP" And not "Microsoft Windows XP Professional"? If you use the "=" sign, you will not be able to hold it because it expects to match the exact string. If you want a partial match then use instr () better. Otherwise, add to "Professional"
After the caption, you can put some debugging in
.... msgbox strCaption & amp; "" & Amp; Len (strCaption) getOperatingSystemCaption = strCaption ....
and try a different way
..... myCaption = getOperatingSystemCaption () msgbox MyCaption & amp; ; "" & Amp; Len (myCaption) if myCaption = "Microsoft Windows XP Premium Home" then ......
also check the length ...
Comments
Post a Comment