Help - Search - Members - Calendar
Full Version: Need Help With VBScript Service Pack 3 Checker
MSFN Forums > Coding, Scripting and Servers > Programming (C++, Delphi, VB, etc.)

   
Google Internet Forums Unattended CD/DVD Guide
dfnkt
Need some help if anyone is good with vbscript. What I need the script to do is query for the existence of service pack version, and then use logic to say "if servicepack = 3 then msgbox "sp3 installed" or "else msgbox "sp3 not installed". I have pasted what I have into a pastebin in a link below. This was hacked together from 2 previous scripts that I wrote. It's been 6 months or more since I worked with VBscript and I'm sure I'm missing something easy.

http://pastebin.com/m328b3e34
pauledavey
Here is some code that will work for you:

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
For each elem in colItems
If instr(elem.CSDVersion, "2") Then
msgbox "Found Service Pack2"
' Place your code here
Else
If instr(elem.CSDVersion, "3") Then
msgbox "Found Service Pack3"
' Place your code here
End If
End If
Next
dfnkt
Thanks paul, much appreciated. Hope I can return the favor.
gunsmokingman
Here is another script that will list if the service pack is installed

QUOTE
CODE
Option Explicit
Dim ColItems, ObjItem, SvcVer, Wmi
  Set Wmi = GetObject("winmgmts:\\.\root\CIMV2")
  Set ColItems = Wmi.ExecQuery("SELECT * FROM Win32_OperatingSystem",,48)
    For Each ObjItem in ColItems
    SvcVer = ObjItem.ServicePackMajorVersion
     If SvcVer = 1 Then WScript.Echo "Service Pack 1 Installed"
     If SvcVer = 2 Then WScript.Echo "Service Pack 2 Installed"
     If SvcVer = 3 Then WScript.Echo "Service Pack 3 Installed"
     If SvcVer = "" Then WScript.Echo "No service Pack Installed"
    Next
ashleysmith55
This is good stuff and just what I'm looking for.

Does anybody know who to check whether Office 2007 SP1 is installed or not in the same script?

Thanks in advance everyone.

Keep up the good work thumbup.gif
Google Internet Forums Unattended CD/DVD Guide
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.