' ********************************************************* ' Suppression des packages de désinstallation des ' mises à jour et Service Pack sous Windows 2000, XP, 2003 ' Supprime les fichiers et les clés de registre. ' ' Alain Vouillon © 2006 ' ********************************************************* On error resume next Dim shell,fso,RepertPK(),CleeBDR() Const HKEY_LOCAL_MACHINE = &H80000002 Set shell=WScript.CreateObject("WScript.Shell") Set fso=WScript.CreateObject("Scripting.FileSystemObject") Windir=shell.ExpandEnvironmentStrings("%systemroot%") BaseBDR="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" TitreMsg="Suppression des packages de désinstallation des mises à jour Microsoft" Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv") strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys set RepWindir=fso.GetFolder(Windir) set SousRep=RepWindir.SubFolders Index=0 For each Rep in SousRep nomRep=Rep.Name If left(nomRep,1)="$" and nomrRep<>"$hf_mig$" then ' si le nom de répertoire commence par $ For Each subkey In arrSubKeys If left(subkey,1)<>"{" then oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "\" & subkey,"UninstallString",strValue If InStr(1,strValue,nomRep,vbTextCompare)>0 Then ' il y a-t-il une clé UninstallString dont la valeur contient nomRep ? Index=Index+1 redim preserve RepertPK(Index),CleeBDR(Index) lennomRep=len(nomRep) CleeBDR(Index-1)=subkey RepertPK(Index-1)=nomRep Exit For end if end if Next End If Next if Index=0 then ret=MsgBox("Aucun package trouvé.",0, TitreMsg) else For i=1 To Index line=line & "Rép:"& RepertPK(i-1) & "...Bdr:" & CleeBDR(i-1) & VBCRLF Next ret=MsgBox("Confirmez-vous la suppression de:" & VBCRLF & line,1, TitreMsg) If ret=1 then line2="" For i=1 To Index fso.DeleteFolder Windir & "\" & RepertPK(i-1),true shell.RegDelete BaseBDR & CleeBDR(i-1) & "\" If err.number<>0 Then line2=line2 & Index & " " err.clear End If LogFile= Windir & "\" & CleeBDR(i-1) & ".log" If fso.FileExists(LogFile) Then fso.DeleteFile LogFile,true If err.number<>0 Then line2=line2 & Index & " " err.clear End If Next If line2<>"" then line2=" Erreur de suppression au(x) package(s) n°" & line2 ret=MsgBox(Index & " package(s) supprimé(s)." & line2 & VBCRLF & line,0, TitreMsg) end if end if wscript.quit