다음을 통해 공유


Unattended windows update uninstall

 

There are different ways to carry out windows update and patch uninstall in unattended way.

This article is collecting these different ways at one place.

The update uninstall is different for updates because of update type, way updates are installed and the OS version.

For understanding different update types please refer to following microsoft link –

http://support.microsoft.com/kb/824684

Here are unattended uninstall way -

1.     Using uninstall string

Most of the updates on windows 2003, XP etc are having a uninstall string property set during installation of the update. We can look in to the windows registry and search out the uninstall string associate with the update and then executing this uninstall command on the command prompt would uninstall the update.

 

objWMIService  = GetObject("winmgmts:{impersonationLevel=Impersonate}!\.\root\default:StdRegProv")

objWMIService.EnumKey HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", updates

For Each update In updates

searchKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" & "\ & update

            objWMIService.GetExpandedStringValue HKEY_LOCAL_MACHINE, searchKey, "UninstallString", strUninstall

            objShell.Run strUninstall, 0, True

Next

2.     Using uninstall package command

Most of the updates on windows 2008, 7 etc support windows update uninstall using an uninstall command similar to below given –

"FORFILES /P %WINDIR%\servicing\Packages /M *<KBid/packagename>*.mum /c "+ """" + "cmd /c echo Uninstalling package @fname && start /w pkgmgr /up:@fname /norestart /quiet" + """"

3.     Using msiexec utility

All patches/updates installed using MSI technology on windows system/servers can be removed using msi command line. MSI 3.x and higher version gives this support.

msiexec  /uninstall <Product.msi | ProductCode> or

msiexec /uninstall <PatchCodeGuid> /package <Product.msi | ProductCode>

For more details refer to microsoft article -

http://technet.microsoft.com/en-us/library/cc759262%28WS.10%29.aspx#BKMK_Uninstall