A technique to get rid of index.dat files

S.Rodriguez - July 31, 2004

Download the tool (58 kb)


Disclaimer : the technique explained in this article is given as is and confers no rights. If this damages your install, that's too bad, but blame yourself for it.

Unlike alternative solutions that can be found on the net, click here for google results, this technique does not require the reboot of your computer.

Internet Explorer uses a dictionary of urls to keep track of everyone's surfing habits. This dictionary is however not deleted when you go in the Internet Explorer options, and delete your temporary internet files or cookies, regardless your caching options. In fact, index.dat is never deleted by any mean, and grows since you last reformated your system! In practice, it's quite probable that the current index.dat file you are using aggregates the collection of url of every single website you visited since you bought your computer! Freaky, right?

To be more accurate, there is not one index.dat file, but more. One is more related to cookies, another is more related to page cache, and the last is related to your history. So there are 3 instances to deal with. And there are such 3 instances for every account in the system. As you can see, the numbers can grow very fast. The point however is that Internet Explorer uses a combination of registry keys to know where to find the index.dat files, and then depending on what it's doing will read/write one or another. To get rid of index.dat files, we need to get rid of all of them, not just one.

Last but not least, those index.dat files are loaded by several processes whenever Windows starts. Typical processes include : Windows explorer itself (explorer.exe), a local process with no particular identifier started by svchost.exe. And on top of that every single Internet Explorer related app will load and lock those files as well including : Internet Explorer itself (iexplore.exe), and all applications hosting the web browser control (google deskbar for instance).

Fortunately, there is a way to identify those apps so that index.dat files can eventually be unlocked. This preliminary step is required before wen can delete the files.

Deleting the files is one thing, it makes a raw clean up. But it has to be said that every single process mentioned above will then create new index.dat file going forward. If you are interested in the clean up, that's a good thing to do. But wait there is more to it, as you'll read below : we can get rid of the info gathering revolving around index.dat files as simple as stated.


Steps to reproduce

  1. unzip the package into some folder. Where the files are unzipped is of no importance. Screenshots below use C:\MyProjects\tmp.
  2. start a command-line prompt
  3. use the handle index.dat statement to find all candidate applications, identified by their name and process id (pid)
  4. kill those apps
  5. iterate the above until only explorer.exe (Windows Explorer) remains listed
  6. launch the killindex.dat.bat script to delete all index.dat files on your system drive
  7. once the Windows task bar reappears, quit the command-line prompt
  8. you are done!


Simple clean up or more

The killindex.dat.bat script file will start a special tool made on purpose to create a dummy index.dat in a strategic place. Using this prevents Internet Explorer from using index.dat to log web pages as well as the history anymore. If it's ok for you, then proceed. Otherwise, if you only need a clean up, then edit the script file and remove the newindexdat.exe statement in it.


Unzip the package

The content of the package

The package is made of the following :

  • handle.exe : it's a sys-internals tool
  • kill.exe : it's a tool from the Windows NT resource kit
  • killindex.dat.bat : the script file
  • newindexdat.exe : it's a simple piece of code that creates a dummy index.dat file (read-only index.dat file, and to be created in a strategic place)


Identify the applications which lock index.dat files

Open up a command-line prompt by typing cmd.exe from the start menu, execute menu option. Then type cd C:\MyProjects\tmp in the prompt to move to the package's place. Of course, replace C:\MyProjects\tmp with your own folder.

Type handle.exe index.dat, you should get a result looking like the following :

Identifying applications which lock index.dat files

Although this looks a bit tough to read, the listing produced by the handle tool is quite simple. Each line lists an occurence of a given process currently accessing index.dat files. In each line, from left to right, there is the process name, the process identifier (pid) and then the actual path to the index.dat file (remember that Windows uses a bunch of index.dat files).

Half of those lines are only synchronization objects related to index.dat files, not files per se, so skip them. They have "\BaseNamedObjects\..." instead of a filepath.

In the screen capture above, actually only 3 processes are of note : svchost.exe, explorer.exe and ggviewer81-81.exe.

Of course, your computer will show a different combination of processes, but this doesn't change anything. The point is to kill all processes except explorer.exe.


Killing all processes except explorer.exe

Killing all processes unlocks index.dat files. Since killing explorer.exe might produce undesirable effects depending on your configuration, it's best to not do it. The script that comes next will take care of that.

To kill a process, you need to type kill -f [pid], where [pid] is the process identifier. In the example above, you would type kill -f 1104 to kill svchost.exe.

All in all, the resulting output of handle should now look like the following :

All applications locking index.dat files are killed, except explorer


Launching the script

It's about time to start the script. The script will do the following :

  • kill Windows explorer (task bar and all Windows explorer views)
  • go to the root directory of your system drive
  • delete all index.dat files
  • launch a tool whose goal is to create a dummy index.dat file
  • start a new instance of Windows explorer (task bar)

To launch the script, type killindex.dat.bat

The code for the script is the following :

pushd .
kill.exe -f explorer.exe
cd \
del /s index.dat

The screenshot below shows what appears on screen while the script executes :

Running the script


Done! well almost

You can now safely quit the command-line prompt. There is no need to reboot the machine, the index.dat files have been deleted.

If you didn't remove the newindexdat.exe statement in the script prior to running it, then applications will have a hard time creating new index.dat files going forward. That's our goal by the way.

What the newindexdat.exe tool does is create a dummy read-only index.dat file in the Internet Explorer temporary file folder, and doing so, it prevents the application from using the index.dat anymore. Neither the temporary files nor the history will work anymore. The cookies will continue to work however, that's a special case where Windows creates a new index.dat in a separate folder to provide support to cookies. That's good since a lot of websites require cookies to work well. That being said, cookies can be enabled/disabled using your Internet Explorer options.

To get back to a normal configuration, you can right-click the index.dat file from your Internet Explorer temporary folder, then remove the read-only protection, then edit the script above and remove the newindexdat.exe statement and run it again. If you can't see the index.dat file, then you need to use windows tricks : if your Internet Explorer temporary file folder is C:\Documents and Settings\<username>\Local Settings\Temporary Internet Files, then type C:\Documents and Settings\<username>\Local Settings\Temporary Internet Files\Content.IE5 in the Windows explorer address bar, and remove the content of the desktop.ini file you'll find in that folder.



That's all folks.