Motorsports Fan

This is a helpware site

Deleting Temporary Files Painlessly

Click Here to make Hardware Hell your homepage.
BIOS Tweaks
& Info

and Vendors

Hacking Your Password Hacking
Your Password

System Problem
Report Form



Link Exchange

Our Awards


Contact Us

Misc. Extras


AMIDiag Review  
AMIDiag Suite 2

Trish's Escape from Hardware Hell Computer Help



   Deleting Temporary Files Painlessly

See Addendum  for Windows XP, ME and 2000

This article is not intended to be a DOS lesson or tutorial, but to show you a simple and painless way that I help keep my drive free from useless file clutter. There are other command variations to do this, however, this is what I have found to work best for me. This article assumes that you already have a basic knowledge of DOS commands, the autoexec.bat file and the consequences of typos and the incorrect use of wildcards.

The temporary internet files folder, history folder and cookies folder contain a file called index.dat. Windows uses index.dat to keep a coded record of the files in the folder where it resides. Windows will NOT let you delete index.dat! If you delete the files in these folders through any Windows method, you are still left with the index.dat containing all the info you thought you just deleted. So much for deleting your tracks! This file can become completely bloated, not to mention corrupted, since it won't match the actual files in the folder. The index.dat file can only be deleted in DOS and are included in your cleanup using the DELTREE command.

All modifications are done in the autoexec.bat file. This is my preference so that these files are deleted each time I boot. The autoexec.bat file is not required after Windows 3.1. If you do not have this file in the root directory of your C:\ drive, just create it in Notepad (make sure that the "Word Wrap" option is OFF) and save as autoexec.bat. The file could actually be saved as "whatever_you_want_to_name.bat" file, but would have to be ran manually and in DOS mode. (Not a DOS window)

If I ever use Netscape, (far and few between) I have the cache files directed to my C:\Windows\Temporary Internet Files location rather than adding yet another directory to clean. If you use a Netscape browser, your cache files may be in the default location at: C:\Program Files\Netscape\users\username\cache (or whatever drive Netscape is installed) Just add another DELTREE line with the path where they can be found.

Here is a copy of my autoexec.bat file with explanation of the commands below. The grayed out lines are what existed before I added the cleanup routine. (Yes, I know neither is necessary, but I have my own reasons) Make sure you change any paths where your files may be kept in different folders than mine and delete out any lines of folders you decide not to have cleaned up.

"my" autoexec.bat File

rem - By Windows Setup - c:\windows\command\mscdex.exe /D:aspicd0 /M:12 /L:I
if exist c:\windows\smartdrv.exe c:\windows\smartdrv.exe 2048 16
DELTREE /y c:\windows\history\*.* > NUL
DELTREE /y c:\windows\tempor~1\*.* > NUL
DELTREE /y c:\windows\temp\*.* > NUL
DELTREE /y c:\windows\cookies\*.* > NUL
DELTREE /y c:\windows\applic~1\micros~1\office\recent\*.* > NUL
DELTREE /y c:\windows\ShellIconCache
if exist del c:\windows\ff*.tmp
if exist del c:\windows\system\advert.dll

Explanations of autoexec.bat commands

@ECHO OFF suppresses the "command" from displaying on the screen. Normally, when commands are executed from a batch file, they are displayed on the screen.  

if exist is a conditional command that says if the file exists, load it. If it does not exist, no big deal, no error message and the command is ignored.

smartdrv.exe is a standard disk cache used to speed things up. It's not needed for Windows, like the old days, but sure speeds things up in DOS. Parameters are the amount of memory in Kb to use.

DELTREE allows you to delete a directory even if it contains files and subdirectories or has hidden, system or read-only attributes. 

/Y Suppresses a prompt to confirm the deletion.

*.*  delete all the files and subdirectories but leave the directory itself. This saves adding an additional command line to recreate the folder. 

> NUL instruction disables output to the screen as your computer boots. Without it, error messages about "files not found" and a file by file line as each file is being deleted.. If a folder is already empty, you would also get an error message. If you would like to see exactly what is going on, just delete the > NUL part.

ShellIconCache is a hidden file in the Windows directory that stores icon cache files. Just like the temporary internet files folder, it becomes very unproductive when the file gets too big. This file can become very bloated and corrupted. (example: black, odd looking icons) If it doesn't seem to work, try replacing ShellIconCache with shelli~1.

if exist del c:\windows\ ff*.tmp deletes garbage files that Office leaves behind, if they exist.

if exist del c:\windows\system\ advert.dll deletes the spyware file (advert.dll) that many demo programs install with their program. This file is always secretly loaded and running on your system. It reports ALL of your online activities back to the originator.

NOTE: Some program installations that require a reboot, may be using the temp folder to store files needed to complete installation upon the reboot. (98lite is one) If so, just put a REM before the DELTREE /y c:\windows\temp\*.* > NUL line. After the installation, go back and remove the REM.

See Addendum  for Windows XP, ME and 2000

Also, we have a great thread going on the subject here. A lot is covered here that I keep seeing in the same emails again and again.

Reader Andy, pointed out another line to add, that I hadn't since I have these files deleted on shutdown with a registry tweak. Thanks, Andy.

DELTREE /y c:\windows\recent\*.* > NUL

Reader Robert adds, "There is another [I think better] way to keep your Netscape cache clear, and speed up Netscape in the process. I set my disk cache to 0 bytes, and memory cache to 4096 kilobytes, and have been running like that for years."

Reader Eric offers his method of removing index.dat files in Win9x.

If you want a quick & easy way to keep your cookies, cache, & history files & those annoying MS index.dat files cleaned up here's a very simply way to do it. I created a RAMDrive using MS DOS RAMDrive.sys. Then I changed the pointers in the registery to point to the RAMDrive & saved cache, cookies, & history junk files there. Now everytime you reboot poof they are gone.

Click on Start...Run...sysedit
Select Config.sys

Copy & paste the following into your config.sys

<--------Begin copy here-------->

DEVICEhigh=C:\WINDOWS\RAMdrive.sys 5120 /E

<--------End copy here-------->

You can change the 5120 to what ever amount of RAM you want to steal. I have 320M RAM so I took 5M. Under Internet Options You could also lower Amount of disk space used for Temp Internet Files to 1 or 2M.

1024 1M RAM
2048 2M RAM
3072 3M RAM
4096 4M RAM
5120 5M RAM
6144 6M RAM
7168 7M RAM

Reboot before editing the registery so you can now see your RAMDrive:
Using regedit go to this Key & set the following:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders

Cache "Enter RAMDrive Letter" ex: F:
Cookies "Enter RAMDrive Letter" ex: F:
History "Enter RAMDrive Letter" ex: F:

Reader Steve gives his method of index.dat cleanup on a network when your index.dat file is stored on the server when  you log out.

I need to permanently disable index.dat file creation, because I'm in a NT network, and the index.dat files from my profile are stored on the server every time I log out, so deleting them at startup won't help keep them away from the server. So I use Hugh E. Morrison's tip on the ME/XE/2k addendum page and create dummy folders named index.dat.
I'm using WIN95 OSR2 and IE 5.5 SP2 btw.. However the next time I start windows, the .dat files are back, inside the C:\WINDOWS\TEMP folder, and windows locks those too, so it probably uses them as well! They're even in the same folder structure, my TEMP folder has Cookies, History and Temporary Internet Files folders in them after that! Solution: I applied the same trick to those files (create more INDEX.DAT dummy folders in temp, every time in autoexec.bat after deleting the windows made index.dat files - could also have deleted TEMP completely and created a new one). 

This time windows/IE gives up and scanning the hard drive for index.dat files reveals there are no more locations windows tries to put them.

The lines I used (VERLAUF is used instead of HISTORY because I'm using a german version of windows):

@echo off
DELTREE /y c:\windows\ShellIconCache >nul
DELTREE /y c:\win95\cookies\*.dat >nul
DELTREE /y c:\win95\tempor~1\content.ie5\*.dat >nul
DELTREE /y c:\win95\verlauf\*.dat >nul
DELTREE /y c:\win95\verlauf\history.ie5\*.dat >nul
DELTREE /y c:\win95\temp\cookies\*.dat >nul
DELTREE /y c:\win95\temp\tempor~1\content.ie5\*.* >nul
DELTREE /y c:\win95\temp\verlauf\*.dat >nul
DELTREE /y c:\win95\temp\verlauf\history.ie5\*.* >nul

DELTREE /y c:\win95\temp\*.tmp >nul

MD c:\win95\cookies\index.dat >nul
MD c:\win95\tempor~1\content.ie5\index.dat >nul
MD c:\win95\verlauf\index.dat >nul
MD c:\win95\verlauf\history.ie5\index.dat >nul
MD c:\win95\temp\cookies\index.dat >nul
MD c:\win95\temp\tempor~1\content.ie5\index.dat >nul
MD c:\win95\temp\tempor~1\content.ie5\desktop.ini >nul
MD c:\win95\temp\verlauf\index.dat >nul
MD c:\win95\temp\verlauf\history.ie5\index.dat >nul
MD c:\win95\temp\verlauf\history.ie5\desktop.ini >nul

Click Here to bookmark Hardware Hell.




Temporary Files


| Apple / Macintosh | Articles | Build / Upgrade | Cdrom / Audio | Company Contacts | CPU / Chipsets | Discussion | Drivers | Download | Full Coverage Sites | Hard Drives | Help Forum | Jumper Settings | Memory | Miscellaneous | Modems / Serial Ports | Monitors / Graphics | Motherboard / Bios | Network | Operating Systems | Optimize / Tweak | Printers / Scanners | Portables | PS/2_OS/2 | Publication | SCSI | Weekly BIOS Tweaks | Trade A Link | My Misc. Links | Missing Children | Extras | Awards | Guestbook | Contact | Home |

last updated 12/30/14
2014 Trish's Escape from Hardware Hell -- Privacy Statement