1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
|
Option Explicit
'On Error Resume Next
Dim AFile, TheFiles, IETemp, IEcontentie5, myTemp, myCookies, myRecent, Afolder, TheFolder, strComputer, objRegistry, strKeyPath, strValueName, strSubPath, arrSubkeys, objSubkey, strValue
Dim FSO, filesys, objWMIService, oss, os, maVersion
'On Error Resume Next
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set oss = objWMIService.ExecQuery ("Select Version from Win32_OperatingSystem")
For Each os in oss
maVersion = Replace(os.Version, ".", "")
Next
Set objRegistry=GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
Set filesys = WScript.CreateObject("Scripting.FileSystemObject")
strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList"
objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubkeys
For Each objSubkey In arrSubkeys
strValueName = "ProfileImagePath"
strSubPath = strKeyPath & "\" & objSubkey
objRegistry.GetExpandedStringValue HKEY_LOCAL_MACHINE,strSubPath,strValueName,strValue
If maVersion > 600000 Then
IETemp = strValue & "\AppData\Local\Microsoft\Windows\Temporary Internet Files\Content.ie5"
IEcontentie5 = strValue & "\AppData\Local\Microsoft\Windows\Temporary Internet Files"
myTemp = strValue & "\AppData\Local\Temp"
myCookies = strValue & "\AppData\Roaming\Microsoft\Windows\Cookies"
myRecent = strValue & "\AppData\Roaming\Microsoft\Windows\Recent"
Else
IETemp = strValue & "\Local Settings\Temporary Internet Files"
IEcontentie5 = strValue & "\Local Settings\Temporary Internet Files\Content.ie5"
myTemp = strValue & "\Local Settings\Temp"
myCookies = strValue & "\Cookies"
myRecent = strValue & "\Recent"
End If
If filesys.FolderExists(IETemp) Then
'WScript.Echo "Dossier " &IETemp& " : Existe"
NettoyageDossier (IETemp)
'WScript.Echo "Dossier IE Temp : Nettoyé"
End If
If filesys.FolderExists(IEContentie5) Then
'WScript.Echo "Dossier " &IEContentie5& " : Existe"
NettoyageDossier (IEContentie5)
'WScript.Echo "Dossier Content.IE5 : Nettoyé"
End If
If filesys.FolderExists(myTemp) Then
'WScript.Echo "Dossier " &myTemp& " : Existe"
NettoyageDossier (myTemp)
'WScript.Echo "Dossier Temporaire: Nettoyé"
End If
If filesys.FolderExists(myCookies) Then
'WScript.Echo "Dossier " &myCookies& ": Existe"
NettoyageDossier (myCookies)
'WScript.Echo "Dossier Cookies : Nettoyé"
End If
If filesys.FolderExists(myRecent) Then
'WScript.Echo "Dossier " &myRecent& " : Existe"
NettoyageDossier (myRecent)
'WScript.Echo "Dossier Fichiers Recent : Nettoyé"
End If
'Pour tester les variable
'msgbox "test:" & strSubPath
'WScript.Echo IETemp &VbCrLf& IEContentie5 &VbCrLf& myTemp &VbCrLf& myCookies &VbCrLf& myRecent
Next
'WScript.Echo strValue
'msgbox "Fin du traitement : Maintenant on peut souffler !"
Sub NettoyageDossier (RepConcerne)
Set FSO = WScript.CreateObject("Scripting.FileSystemObject")
set Afolder=FSO.GetFolder (RepConcerne)
Set TheFiles = AFolder.Files
Set TheFolder = Afolder.SubFolders
For Each AFile In TheFiles
On Error Resume Next
AFile.Delete
On Error Goto 0
Next
For Each AFile In TheFolder
On Error Resume Next
AFile.Delete
On Error Goto 0
Next
End Sub |
Partager