Guest User

Untitled

a guest
Jan 9th, 2013
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. ' *********************************************************
  2. ' Suppression des packages de désinstallation des
  3. ' mises à jour et Service Pack sous Windows 2000, XP, 2003
  4. ' Supprime les fichiers et les clés de registre.
  5. '
  6. ' Alain Vouillon © 2006
  7. ' *********************************************************
  8. On error resume next
  9.  
  10. Dim shell,fso,RepertPK(),CleeBDR()
  11. Const HKEY_LOCAL_MACHINE = &H80000002
  12. Set shell=WScript.CreateObject("WScript.Shell")
  13. Set fso=WScript.CreateObject("Scripting.FileSystemObject")
  14.  
  15. Windir=shell.ExpandEnvironmentStrings("%systemroot%")
  16. BaseBDR="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
  17. TitreMsg="Suppression des packages de désinstallation des mises à jour Microsoft"
  18.  
  19. Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
  20. strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
  21. oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
  22.  
  23. set RepWindir=fso.GetFolder(Windir)
  24. set SousRep=RepWindir.SubFolders
  25. Index=0
  26.  
  27. For each Rep in SousRep
  28. nomRep=Rep.Name
  29. If left(nomRep,1)="$" and nomrRep<>"$hf_mig$" then ' si le nom de répertoire commence par $
  30. For Each subkey In arrSubKeys
  31. If left(subkey,1)<>"{" then
  32. oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "\" & subkey,"UninstallString",strValue
  33. If InStr(1,strValue,nomRep,vbTextCompare)>0 Then ' il y a-t-il etc. (coupé sinon possible erreur)
  34. Index=Index+1
  35. redim preserve RepertPK(Index),CleeBDR(Index)
  36. lennomRep=len(nomRep)
  37. CleeBDR(Index-1)=subkey
  38. RepertPK(Index-1)=nomRep
  39. Exit For
  40. end if
  41. end if
  42. Next
  43. End If
  44. Next
  45.  
  46. if Index=0 then
  47. ret=MsgBox("Aucun package trouvé.",0, TitreMsg)
  48. else
  49. For i=1 To Index
  50. line=line & "Rép:"& RepertPK(i-1) & "...Bdr:" & CleeBDR(i-1) & VBCRLF
  51. Next
  52. ret=MsgBox("Confirmez-vous la suppression de:" & VBCRLF & line,1, TitreMsg)
  53. If ret=1 then
  54. line2=""
  55. For i=1 To Index
  56. fso.DeleteFolder Windir & "\" & RepertPK(i-1),true
  57. shell.RegDelete BaseBDR & CleeBDR(i-1) & "\"
  58. If err.number<>0 Then
  59. line2=line2 & Index & " "
  60. err.clear
  61. End If
  62. LogFile= Windir & "\" & CleeBDR(i-1) & ".log"
  63. If fso.FileExists(LogFile) Then fso.DeleteFile LogFile,true
  64. If err.number<>0 Then
  65. line2=line2 & Index & " "
  66. err.clear
  67. End If
  68.  
  69. Next
  70. If line2<>"" then line2=" Erreur de suppression au(x) package(s) n°" & line2
  71. ret=MsgBox(Index & " package(s) supprimé(s)." & line2 & VBCRLF & line,0, TitreMsg)
  72. end if
  73. end if
  74.  
  75. wscript.quit
Advertisement
Add Comment
Please, Sign In to add comment