' Désinstallation de Diskeeper sous Windows 2000 ' ' Jean-Claude BELLAMY © 2000 ' ---------------------------------------------- ' On Error Resume Next Dim shell, fso, rep(3), dkfile(5) Set shell = WScript.CreateObject("WScript.Shell") Set fso =WScript.CreateObject("Scripting.FileSystemObject") dkfile(1)="dfrgfat.exe" dkfile(2)="dfrgntfs.exe" dkfile(3)="dfrgsnap.dll" dkfile(4)="dfrgres.dll" dkfile(5)="dfrgui.dll" ' Clefs principales MSkey="HKLM\SOFTWARE\Microsoft\" NodeKey=MSkey & "MMC\NodeTypes\{476e644a-aaff-11d0-b944-00c04fd8d5b0}\Extensions\" CLSID="{43668E21-2636-11D1-A1CE-0080C88593A5}" SourcePathKey=MSKey & "Windows\CurrentVersion\Setup\SourcePath" SPSourcePathKey=MSKey & "Windows\CurrentVersion\Setup\ServicePackSourcePath" NTSourcePathKey=MSKey & "Windows NT\CurrentVersion\SourcePath" ' Sauvegarde de clefs de setup SourcePath=ReadKey(SourcePathKey) SPSourcePath=ReadKey(SPSourcePathKey) NTSourcePath=ReadKey(NTSourcePathKey) ' Chemins de setup Windir=Shell.ExpandEnvironmentStrings("%windir%") & "\" rep(1)=SPSourcePath & "\i386\" rep(2)=Windir & "system32\dllcache\" rep(3)=Windir & "system32\" msg1="Ce script sert à désinstaller Diskeeper" & VBCRLF & VBCRLF msg2="Il supprime les fichiers :" & VBCRLF for i=1 to 5 msg2=msg2 & "- " & dkfile(i) & VBCRLF next msg3="dans les répertoires :" & VBCRLF for i=1 to 3 if fso.FolderExists(rep(i)) then msg3=msg3 & "- " & lcase(rep(i)) & VBCRLF next msg4=VBCRLF & "ainsi que certaines clefs de la BDR" & VBCRLF msg5="faisant référence à Diskeeper" & VBCRLF & VBCRLF msg6="Voulez-vous continuer ?" intDoIt = MsgBox(msg1 & msg2 & msg3 & msg4 & msg5 & msg6, vbYesNo + vbQuestion, "UninstDKP - JCB © 2000") If intDoIt <> VbYes Then WScript.Quit ' Suppression des clefs de setup DelKey(SourcePathKey) DelKey(SPSourcePathKey) DelKey(NTSourcePathKey) ' Suppression des fichiers for j=1 to 3 ' test si nom de répertoire existant (test du cas ou aucun SP n'a été installé) ' NB: dans le cas du SP, seuls les fichiers 1 à 3 existent en principe if fso.FolderExists(rep(j)) then for i=1 to 5 DelFile(rep(j) & dkfile(i)) next end if next ' Suppression des clefs Défrag DelKey(MSkey & "Windows\CurrentVersion\Explorer\MyComputer\DefragPath\") DelKey(MSkey & "Dfrg\") DelKey(MSkey & "MMC\Snapins\" & CLSID & "\") DelKey(NodeKey & "ContextMenu\" & CLSID) DelKey(NodeKey & "NameSpace\" & CLSID) DelKey("HKCR\CLSID\{80EE4901-33A8-11d1-A213-0080C88593A5}") DelKey("HKCR\CLSID\{80EE4902-33A8-11d1-A213-0080C88593A5}") ' Restauration des clefs de setup WriteKey SourcePathKey,SourcePath WriteKey SPSourcePathKey,SPSourcePath WriteKey NTSourcePathKey,NTSourcePath Wscript.echo "C'est fini!" Wscript.quit '================================================ Sub DelFile(filespec) On Error Resume Next if fso.FileExists(filespec) then fso.DeleteFile(filespec) If Err.Number<>0 Then Wscript.Echo "Erreur dans la suppression du fichier" & vbcrlf & filespec end if else Wscript.echo "Fichier " & filespec & " inexistant" end if end sub '================================================ Function ReadKey(key) On Error Resume Next ReadKey=shell.RegRead(key) If Err.Number<>0 Then Wscript.Echo "Erreur dans la lecture de la clef" & vbcrlf & key End If end function '================================================ Sub WriteKey(key,value) On Error Resume Next shell.RegWrite key,value,"REG_SZ" If Err.Number<>0 Then Wscript.Echo "Erreur dans l'écriture de la clef" & vbcrlf & key End If end sub '================================================ Sub DelKey(key) On Error Resume Next shell.RegDelete(key) If Err.Number<>0 Then Wscript.Echo "Erreur dans la suppression de la clef" & vbcrlf & key End If end sub '================================================