I am having a problem with my script. I am a noob when it comes to VBS so please excuse my ignorance. I echo the value of osversion varible and it has my os version in it. But then once it enters into the IF statement it is always false which is should be true because I am running Microsoft Windows 7 Ultimate which is what I am making osversion = to in the if statement.
I am curious what I am doing wrong. Thanks for your help in advanced.
---------------------------------------------
' Original script created by:
' Author Guy Thomas ' Version 1.4 - November 2005
' -------------------------------------------------------'
'Option Explicit
Dim objWMIService, objItem, colItems, osversion
Dim strComputer, strList
strComputer = "."
' WMI Connection to the object in the CIM namespace
Set objWMIService = GetObject("winmgmts:\\" _
& strComputer & "\root\cimv2")
' WMI Query to the Win32_OperatingSystem
Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
' For Each... In Loop (Next at the very end)
For Each objItem in colItems
osversion = objItem.Caption
WScript.Echo osversion
If osversion = "Microsoft Windows 7 Ultimate" Then
WScript.Echo "It worked!"
Else
WScript.Echo "It did not work"
End If
Next
WSCript.Quit
--------------------------------------------------
I am curious what I am doing wrong. Thanks for your help in advanced.
---------------------------------------------
' Original script created by:
' Author Guy Thomas ' Version 1.4 - November 2005
' -------------------------------------------------------'
'Option Explicit
Dim objWMIService, objItem, colItems, osversion
Dim strComputer, strList
strComputer = "."
' WMI Connection to the object in the CIM namespace
Set objWMIService = GetObject("winmgmts:\\" _
& strComputer & "\root\cimv2")
' WMI Query to the Win32_OperatingSystem
Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
' For Each... In Loop (Next at the very end)
For Each objItem in colItems
osversion = objItem.Caption
WScript.Echo osversion
If osversion = "Microsoft Windows 7 Ultimate" Then
WScript.Echo "It worked!"
Else
WScript.Echo "It did not work"
End If
Next
WSCript.Quit
--------------------------------------------------