'Remove KB2412171 Outlook patches, original and re-release. '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 'version 2.1 1/24/11. No functional changes. Some code cleanup, and added remarks for clarity Option Explicit On Error Resume Next dim bEcho 'set below to false to remove status messages echoed to console bEcho=True Const HKEY_LOCAL_MACHINE = &H80000002 'GUID of re-released patch Const strNewPatch = "{752A0B7C-BD24-4362-AC86-AB63FEE6F46F}" 'GUID of original patch Const strOldPatch = "{7961E819-93A5-40A8-8469-4BE2FBBFACEF}" 'Searching Uninstall Key Const strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" dim WshShell: Set WshShell = WScript.CreateObject("WScript.Shell") Dim quote: quote=chr(34) 'Force cscript host 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) 'Exit with errorlevel 500 End If 'Connect to Local WMI registry provider Dim objReg: Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv") 'Uninstall second, re-release patch if present, then original if present 'The second number parameter is the patch version number which is recorded in the name of the uninstall log. UninstallPatch strNewPatch, 2 UninstallPatch strOldPatch, 1 Sub UninstallPatch(strPatch, strVer) 'Connect to uninstall key. We need to do this each time, because after 're-release patch is uninstalled, system may roll back to original patch if installed. objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys Dim subKey, oExec, arrSubKeys Dim strUninstall, strCommand 'Find the GUID for the patch. it is part of the subkey names For Each subkey In arrSubKeys If InStr(subKey, strPatch) > 0 Then strUninstall = WshShell.RegRead("HKLM\" & strKeyPath & "\" & subkey & "\UninstallString") 'Note location of log below is %temp%. You can edit this path 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 'Run the command line, above Set oExec = WshShell.Exec(strCommand) 'Wait until done Do While oExec.Status = 0 WScript.Sleep 100 Loop 'Wait a little more as a precaution WScript.sleep 500 'Capture Exit code If oExec.ExitCode <> 0 Then If bEcho Then WScript.Echo "Warning: Non-zero exit code from MSIExec, " & oExec.exitcode 'Exit with error code returned by MSIExec. This sets an errorlevel and is detected by ConfigMgr. WScript.Quit(oExec.exitcode) End If 'Once GUID is found, exit loop enumerating subkeys 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