Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cannot Delete Files?

Status
Not open for further replies.

drkestrel

MIS
Sep 25, 2000
439
GB
I have created the following simple VB script file, attempting to automate the deletion of All Cookies and Temporary Internet Files. But the results is that whilst browsing from Window's Explorer, I can't see any cookies files, looking at IE5's Tools->Internet Options->Settings->View Files, I could still see all cookies and temporary files?? What's wrong? How could i delete all files. What's wrong?

Code:
Dim fso
Dim folder


Set fso    = WScript.CreateObject("Scripting.FileSystemObject")
Set folder = fso.getfolder("c:\winnt\profiles\userID\Local Settings\Temporary Internet Files")
delAllFolders(folder)

Set folder = fso.getfolder("c:\winnt\profiles\userID\Cookies")
delAllFolders(folder)

Set folder = fso.getfolder("c:\winnt\Temporary Internet Files")
delAllFolders(folder)




Private Sub delAllFolders(myFolder)
   Dim myFolders
   Dim eachFolder
   
   Set myFolders = myFolder.SubFolders
   
   delAllFiles(myFolder)
   For each eachFolder in myFolders
       delAllFolders(eachFolder)
   Next
   
end Sub

Private Sub delAllFiles(myFolder)
   Dim myFiles
   Dim eachFile
   Dim tmp
   
   Set myfiles= myFolder.files
   
   For each eachFile In myFiles
   
    if (eachFile.Name <> &quot;index.dat&quot;) and not(eachFile.Attributes and 1)  Then
        'tmp= myFolder.Name & &quot;--&quot; & eachFile.Name & &quot;-&quot; &  eachFile.Attributes
       ' MsgBox tmp
        eachFile.Delete
    end if
   Next
   
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top