SpaceSaver wrote:
> Question:
>
> HowTo easily get rid of previously installed security fixes that is
> superseeded by a new servicepack or security roll-up package ?
>
> Detail:
> While applying a new servicepack or security roll-up package there is
> normally a bunch of previously installed security fixes that will be replaced
> but they will
> still remain in their respective "$NTUninstall" folder located within the
> "SystemRoot" directory (as well present in the Add/Remove Programs dialog)
> and will eventually allocate a rather huge amount of diskspace (to my opinion
> rather unnecessary). To my knowledge there is no automatic "clean-up" process
> builtin that can be activated when fex. installing a new servicepack, assumed
> that rollback to a previous servicepack including security fixes not is
> needed.
>
> Platforms:
> Windows 2000 Server
> Windows Server 2003
Hi,
A service pack install will remove the entries in Add/Remove Programs
for the updates it replaces, but it will not delete the uninstall
folders (this in case you uninstall the service pack)
Below is a VBScript (put it in a .vbs file) that I have written that
will remove the uninstall folder (and the Add/Remove Programs entry
if one exists) for all hotfixes that creates $ntuninstall... folders
under the Windows folder.
Note: This will not uninstall the update itself, only the
uninstall folder and the Add/Remove Programs entry.
'--------------------8<----------------------
Set oShell = CreateObject("WScript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")
sWinDir = oFSO.GetSpecialFolder(0)
Set oFolder = oFSO.GetFolder(sWinDir)
Set oDictionary = CreateObject("Scripting.Dictionary")
For Each oSubFolder In oFolder.SubFolders
sFolderName = LCase(oSubFolder.Name)
sFolderPath = LCase(oSubFolder.Path)
If Left(sFolderName, 13) = "$ntuninstallq" _
Or Left(sFolderName, 14) = "$ntuninstallkb" Then
' get the update name for the registry delete
sUpdateName = Mid(sFolderName, 13, Len(sFolderName) - 13)
' never delete folders/files while enumerating a file/folder collection
' adds them to a dictionary object for later handling instead
oDictionary.Add sUpdateName, sFolderPath
End If
Next
sDeleted = ""
For Each sUpdateName In oDictionary.Keys
sDeleted = sDeleted & vbCrLf & sUpdateName
sFolderPath = oDictionary.Item(sUpdateName)
On Error Resume Next
' remove entry in Add/Remove Programs
oShell.RegDelete "HKLM\SOFTWARE\Microsoft\Windows\" _
& "CurrentVersion\Uninstall\" & sUpdateName & "\"
On Error Goto 0
' delete the uninstall folder
oShell.Run "%Comspec% /C RD /S /Q " _
& Chr(34) & sFolderPath & Chr(34), 0, True
Next
If sDeleted <> "" Then
MsgBox "The uninstall data for the following updates are now removed:" _
& vbCrLf & UCase(sDeleted)
Else
MsgBox "No updates found to remove the uninstall data for."
End If
'--------------------8<----------------------
--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scr...r/default.mspx