Jump to content
MSFN is made available via donations, subscriptions and advertising revenue. The use of ad-blocking software hurts the site. Please disable ad-blocking software or set an exception for MSFN. ×

Need Help With VBScript Service Pack 3 Checker


Recommended Posts

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

Link to post
Share on other sites

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

Link to post
Share on other sites

Here is another script that will list if the service pack is installed

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

Link to post
Share on other sites
  • 1 month later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...