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