I’m in the process of writing a deployment script for Office 2010 and several other applications, one of the issues we ran into in testing were some computers still had XP SP2, so I wanted to code in a a safety measure for this.
I came up with this
Set colOperatingSystem = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystem
ServicePack = objOperatingSystem.ServicePackMajorVersion
Next
IF not ServicePack = "3" Then
MsgBox "WARNING: prerequisite to installing Microsoft Office 2010 Professional you must first install service pack 3" & VbCrlf & "your current Service Pack Version is " & ServicePack
ELSE
'Do Nothing
END IF
I plugged it into an XP SP2 machine and got the warning popup On_WindowLoad, so I was pleased, but then as soon as I plugged it into my windows 7 machine it throws the same message, digging into powershell a bit I realize that since windows 7 reports it’s ServicePackMajorVersion number as “1” so it doesn’t meet the conditional,
Hoping someone might have an idea how to write an IF / Conditional statement to bypass the Windows 7 PC’s, I looked at build number which is 7601, but not sure how I would nest these
To test if you are running under Windows XP you must check if the
Versionproperty of theWin32_OperatingSystemWMI class start with5.1Check this sample