'Remove Outlook patch 2412171 'Alan dot Kaplan at VA dot Gov 1/20/11 'run this with cscript //b uninstalloutlook2412171.vbs on local machine 'version 2, 1/21/11 forces cscript and switches to EXEC to capture error codes Option Explicit On Error Resume Next dim bEcho 'set below to false to remove status bEcho=True Const HKEY_LOCAL_MACHINE = &H80000002 Const strNewPatch = "{752A0B7C-BD24-4362-AC86-AB63FEE6F46F}" Const strOldPatch = "{7961E819-93A5-40A8-8469-4BE2FBBFACEF}" dim WshShell: Set WshShell = WScript.CreateObject("WScript.Shell") dim quote dim strUninstall dim strcommand quote=chr(34) If (Not IsCScript()) Then 'If not CScript, re-run with cscript... WshShell.Popup "Error. You must run this with the command cscript //b " & quote & WScript.ScriptFullName & quote,20,"Requires CScript" WScript.Quit(500) '...and stop running as WScript End If 'First, find the GUID dim strComputer: strComputer = "." Dim objReg, strKeyPath, arrSubKeys Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\"&strComputer & "\root\default:StdRegProv") strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" UninstallPatch strNewPatch, 2 UninstallPatch strOldPatch, 1 Sub UninstallPatch(strPatch, strVer) objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys Dim subKey, oExec For Each subkey In arrSubKeys If InStr(subKey, strPatch) > 0 Then strUninstall = "" strUninstall = WshShell.RegRead("HKLM\" & strKeyPath & "\" & subkey & "\UninstallString") strcommand = "%windir%\System32\" & strUninstall & " REBOOT=" & quote & "ReallySuppress" & quote & " /Q /L %temp%\Remove_KB2412171_v" & strVer & ".log" if bEcho then wscript.echo "Uninstalling Patch v." & strver Set oExec = WshShell.Exec(strCommand) 'Wait until done Do While oExec.Status = 0 WScript.Sleep 100 Loop 'wait a little more wscript.sleep 500 'Capture Exit code If oExec.ExitCode <> 0 Then WScript.Echo "Warning: Non-zero exit code from MSIExec, " & oExec.exitcode 'Exit With MSIExec Error Code WScript.Quit(oExec.exitcode) End If Exit For End If Next End Sub Function IsCScript() If (InStr(UCase(WScript.FullName), "CSCRIPT") <> 0) Then IsCScript = True Else IsCScript = False End If End Function