VB - Deleting Temporary Internet Files

Posted on 2001-08-09
Last Modified: 2010-05-02
Anyone know how to implement VB code to delete the files in "C:\Windows\Temporary Internet Files"?

I have tried using "Dir" function and "FileSystemObject" object, however they do not recognize the entries in that directory as actual files.

Any help would be appreciated.
Question by:Marker
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +3

Expert Comment

ID: 6370378
shell ("attrib -r c:\where\ever\*.*")
shell ("del c:\where\ever\*.*")

thats it


LVL 20

Expert Comment

ID: 6370382
Here is the only example that I have found that works using vb code:

Author Comment

ID: 6370465
To: andysalih,

This solution does not work, since the entries in "C:\Windows\Temporary Internet Files" directory do not appear as normal, hidden or system files to the DOS shell.

Thanks for the effort though :)

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Expert Comment

ID: 6370877

Kill "C:\Windows\Temporary Internet Files\*.*"

Expert Comment

ID: 6370903
Hi Dave_Greene!

Here's just my opinion.  The last time I manually deleted all the files in the "C:\Windows\Temporary Internet Files", my IE5 gave me some "cannot open the search page" or something like that.

So, using

Kill "C:\Windows\Temporary Internet Files\*.*"

may cause your IE to be down since it's more or less the smae thing.  Deleting of cookies killed my IE.  Mail would still work though.


On the other hand, you may want to kill those files using Dave_Greene's method, but do a check on whether it's a cookie ot not.  Remember, delete those files only IF they are NOT cookies.  The one and only thing that caused the 'death' of my IE was the deleting of cookies.  Delete any thing you want in that folder, just don't touch the cookies.

That's it!

glass cookie : )
LVL 16

Accepted Solution

Richie_Simonetti earned 50 total points
ID: 6371082

Author Comment

ID: 6373534
To Richie Simonetti,

Thanks, this example is nice and clean and works well, I would recommend it to others.

To Glass Cookie,

Thanks for the feedback, the example from Ritchie checks if the entry is a cookie and avoids the mishaps you may have encountered by deleting any cookies in this directory.

To Hes,

This code does work, but seems a little complicated (I am a total Newbie at VB so it's easy to confuse me...:) the example from Ritchie is a cleaner method.

Thanks to all who replied....

LVL 16

Expert Comment

ID: 6373607
You are welcome. Glad to help.
LVL 20

Expert Comment

ID: 6374156
No problem, just glad you got a solution you like and can use :)

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question