dfnkt Posted June 16, 2008 Share Posted June 16, 2008 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 comment Share on other sites More sharing options...
pauledavey Posted June 16, 2008 Share Posted June 16, 2008 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 colItemsIf instr(elem.CSDVersion, "2") Then msgbox "Found Service Pack2"' Place your code hereElseIf instr(elem.CSDVersion, "3") Then msgbox "Found Service Pack3"' Place your code hereEnd IfEnd IfNext Link to comment Share on other sites More sharing options...
dfnkt Posted June 16, 2008 Author Share Posted June 16, 2008 Thanks paul, much appreciated. Hope I can return the favor. Link to comment Share on other sites More sharing options...
gunsmokingman Posted June 17, 2008 Share Posted June 17, 2008 Here is another script that will list if the service pack is installedOption 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 comment Share on other sites More sharing options...
ashleysmith55 Posted July 31, 2008 Share Posted July 31, 2008 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 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now