On error resume next Set WshShell = WScript.CreateObject("WScript.Shell") Set fso = CreateObject("Scripting.FileSystemObject") Set objShell = CreateObject ("Shell.Application") OldFileNbrDay = -8 OldFileDate = Cdate(DateAdd("d",OldFileNbrDay,Date) & " " & Time) Const ForAppending = 8 Set Va = fso.OpenTextFile("C:\demarrage.log", ForAppending, True) For Each Folder in objShell.Namespace(WshShell.ExpandEnvironmentStrings("%HOMEDRIVE%") & "\Documents and Settings").Items TempRep = Folder.path & "\Local Settings\Temp" call SearchDeleteItem(TempRep) Next TempRep = WshShell.ExpandEnvironmentStrings("%windir%") & "\Temp" call SearchDeleteItem(TempRep) Va.Close Wscript.Quit Sub SearchDeleteItem(rep) On error resume next set F = fso.GetFolder(rep) set F1 = F.SubFolders For Each objItem in F1 call SearchDeleteItem(objItem.Path) next set F1 = F.Files For Each objItem in F1 If objItem.DateLastAccessed < OldFileDate then Wscript.echo "Suppr. du fichier " & objItem.Path Va.Writeline "Suppr. du fichier temporaire: " & objItem.Path ff = fso.GetFile(objItem.Path) If ff.Attributes AND 1 Then 'read only ff.Attributes = ff.Attributes XOR 1 End If If ff.Attributes AND 2 Then 'hidden ff.Attributes = ff.Attributes XOR 2 End If If ff.Attributes AND 4 Then 'system ff.Attributes = ff.Attributes XOR 4 End If fso.DeleteFile(objItem.Path),DeleteReadOnly end if Next If F1.Count = 0 then If rep <> TempRep then Wscript.echo "Suppr. du dossier " & rep Va.Writeline "Suppr. du dossier temporaire: " & rep f = fso.GetFolder(rep) If f.Attributes AND 2 Then 'Hidden f.Attributes = f.Attributes XOR 2 End If If objFolder.Attributes AND 4 Then 'System f.Attributes = f.Attributes XOR 4 End If fso.DeleteFolder(rep),DeleteReadOnly end if end if End Sub