June 16, 200818 yr 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
June 16, 200818 yr 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
June 17, 200818 yr 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
July 31, 200818 yr 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
Create an account or sign in to comment