PDA

View Full Version : XP TIP: Delete index.dat(s)



Terry Porritt
16-11-2003, 03:59 PM
The delete command in Windows XP has more useful switches than in dos6.22 and dos7.

So if you tend to paranoia and wish to delete the various index.dat files, it can be done from the Registry as Windows is being loaded. That way you dont get the message that the files arent accessible because they are in use as you would get if you tried to delete them with XP running.

Make a batch file with this line in it:
del /s /q C:\Documents and Settings\index.dat

and call it delindex.bat or whatever you like, and put it in C:\.

Open Regedit and navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Curr entVersion\Run

Make a new String Value, name it delindex, and then via right click Modify, give it the value:

%ComSpec% /c c:\zapindex.bat

The %ComSpec% command calls up a new instance of cmd.exe, and all the index.dat in Documents and Settings and its sub-folders will be deleted.
When Windows starts new index.dats will be made as neccessary but will be minimum size.

This is similar to deleting the index.dat in Win 98 from dos, but in this case a separate boot to dos is not neccessary.

To see the switches available just type del /? and %ComSpec% /? from the command line prompt.

Any comments gladly received :)

Fire-and-Ice
16-11-2003, 05:37 PM
Argh it didn't work for me. All index.dat file sizes remained the same. :-(

Am I doing the batch file thing wrong? All I did was paste the line

del /s /q C:\Documents and Settings\index.dat

into notepad and saved it as delindex.bat

More advice would be appreciated. :-)

-=JM=-
16-11-2003, 07:14 PM
%ComSpec% seems to just run cmd.exe. You _should_ be able to not use the batch file at all. By running cmd /c the c switch is used to "/C Carries out the command specified by string and then terminates". So you could just have the contents of the batch file after the "/c" and it should still execute correctly.

Another handy thing I've found for XP is that if you use a hosts file and find yourself having to enable/disable it a bit. A shortcut with the code: %windir%\System32\cmd.exe /c if exist %windir%\system32\drivers\etc\hosts (ren %windir%\system32\drivers\etc\hosts hosts.disabled) else (ren %windir%\system32\drivers\etc\hosts.disabled hosts)

works quite well as a toggle switch.

mark.p
16-11-2003, 07:51 PM
Wasn't NT based MS Windows meant to make the command line redundent?

Terry Porritt
16-11-2003, 08:18 PM
Thanks for the comments all.
Fire&Ice: If all is ok then your(Cookie) index.dat file may already be small. The file seems to increase in increments of 16KB, with a minimum size of 16KB.
Mine was 48KB, and after applying the batch file it fell to 32KB with a small handful of permanent cookies I keep such as PressF1, Live365, and a few other forums and favorite site cookies.

I turned off Cookie Crusher and set Privacy in IE to accept all cookies and browsed a bit to collect about another dozen maybe, but the index.dat was still at 32KB.

Just pasting that command line into notepad should be ok. Perhaps a carriage return at the end of the line is in order, or is that for making a .reg file? My brains cells are only short term :)

JM. Interesting. I found I needed the %ComSpec% in the Registry Key to call up a separate instance of cmd.exe, otherwise I was getting an error message to say the index.dat were not accessible and were in use, just as the Desktop was coming up when windows was loading.

I do the same as you with a hosts toggle, but being simple minded I made 2 batch files one for hosts on, one for hosts off.
I found I needed to do this for Live 365 streaming audio stations if I wanted to register a station as a favorite, ( the station author gets a discount if you do this). There was something in my hosts file preventing a drop down box working to set a favorite, and their help desk didnt know.

This is one of the toggles:

@echo off
c:
cd\windows\system32\drivers\etc
if exist hosts ren hosts hosts.off
cls
:end


The other says:

@echo off
c:
cd\windows\system32\drivers\etc
if not exist hosts ren hosts.off hosts
cls
:end

Then I have 2 shortcuts to the batch files, crude but it works.

Mark.p:
No Mark, in fact there seems to be more useful command line commands in XP with useful switches than in dos 7. Im only just starting to explore them. Deleting index.dat was my first stab at this in XP.

In dos there were just 2 switches for del, in XP there are 5.

mark.p
16-11-2003, 08:48 PM
>
> Mark.p:
> No Mark, in fact there seems to be more useful
> command line commands in XP with useful switches than
> in dos 7. Im only just starting to explore them.
> Deleting index.dat was my first stab at this in XP.
>
> In dos there were just 2 switches for del, in XP
> there are 5.

Maybe I should have put [sarcasm] before the post.

Terry Porritt
16-11-2003, 08:58 PM
Oh dear, I must be too serious tonight to take the hint :) Yes ok, it is just dos more or less, by another name.

MS did try from Win95 on to pretend dos wasnt there.

mark.p
16-11-2003, 09:09 PM
;) Here's MS's XP Command ref page-http://www.microsoft.com/technet/treeview/default.asp?url=/technet/prodtechnol/winxppro/proddocs/ntcmds.asp

Fire-and-Ice
16-11-2003, 09:22 PM
None of the index.dat files decreased in size. One of them is 2448KB in the C:\Documents and Settings\username\Local Settings\Temporary Internet Files\Content.IE5 folder and the next largest index.dat is C:\Documents and Settings\username\Local Settings\History\History.IE5 at 416KB. Both are in the same user account which has actually been removed so goodness knows why it is still in Win Explorer.

All the other index.dat files range from 16KB to 48KB but haven't been recreated since trying that batch file so it couldn't of worked.

Incidentally a cleaning program (can't remember which one) couldn't of cleared the index.dat files in the old user account either because it was deleted a long time ago. Rather interesting really. ;-)

Terry Porritt
16-11-2003, 09:55 PM
Well, I cant give an answer. Just to check again I rebooted after reading your post, and all my index.dat immediately after re-booting doing anything else have a Date Modified 11/16/2003 at 9:39pm, and maximum size is 32KB

Re-check your entry in the registry, this is a .reg file for putting the line in the registry:

REGEDIT4

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Curr entVersion\Run]
"delindex"="%ComSpec% /c c:\\delindex.bat"

Instead of .bat you can use .cmd, then interesting the file type changes from ms-dos batch file to cmd file

Terry Porritt
16-11-2003, 09:56 PM
.......before doing anything else.......

Terry Porritt
16-11-2003, 10:01 PM
Oh god, I'll get it right eventually a double back slash has somehow appeared when i exported the entry , it should be:

REGEDIT4

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Curr entVersion\Run]
"delindex"="%ComSpec% /c c:\delindex.bat"

Terry Porritt
16-11-2003, 10:04 PM
Give up X-(
Now a space has appeared in Current.

mark.p
16-11-2003, 10:29 PM
Seeee MS Windows has a mind of its own ;) lol. You have been assimilated!!

Fire-and-Ice
16-11-2003, 10:48 PM
Nope, still no go. :-(

Even tried importing your registry file (with the space eliminated ;-) ) with no difference. It just doesn't want to work for me. :_|

Terry Porritt
17-11-2003, 07:54 AM
OK I'll go back to the drawing board :(

One misconception Ive had is the time stamp for index.dat. I just disabled the bat file and rebooted, and all the index.dat files have the time of re-boot, so that isnt a test to check if the deletion is working. I had assumed the time stamp was the time an addition was last made.

I need a larger index.dat to work with.

-=JM=-
17-11-2003, 08:36 AM
Just looking at the batch file you've got for deleting the files, isn't that only going to delete C:\Documents and Settings\index.dat. Perhaps changing the directory to Documents and Settings or just to plain old C:\ then running the del /s index.dat

Fire-and-Ice
17-11-2003, 01:11 PM
I must have some sort of weird setup because even trying the suggestions by -=JM=- and a few of my own it still doesn't work. The only way to get rid of those index.dat files is by using a cleanup program that deletes them. :-(

Thanks for the tip anyway Terry, it was a good try and if it works for you all is well and good. ;-)

Terry Porritt
17-11-2003, 01:59 PM
Im still at the drawing board :)

The /s switch in del is supposed to go through all the sub-directories of c:\documents and settings and look for index.dat.

I seem to have now got myself knotted up as I cant delete the index.dat in the Administrator folder c:\documents and settings\Terry\Cookies\index.dat (Terry is Administrator)

It is all something to do with logging on as another user with administrative rights, then one is supposed to be able to delete index.dat.

As something extra I've just found this site here (http://www.markusjansson.net/eienbid.html) scroll down a bit to find a method of removing index.dat based on removing the folders containing index.dat. There is a .cmd file called exp.cmd which just uses the remove directory command.

This works ok but as well it removes all the cookies, which is not what I want. I would like to clear the index.dat whilst leaving selected cookies.

-=JM=-
17-11-2003, 02:26 PM
Yes you're quite right Terry, it does go through all the sub-directories, was rather early in the morning and I had messed it up somehow.

Hmmm I just tried getting it to output the results to a text file... it doesn't log the "file can not be deleted" parts though.

Terry Porritt
17-11-2003, 03:06 PM
These users and administrators are new to me, but I just logged off as administrator (Terry by default) and logged on as "Guest" and was able to delete index.dat in c:\documents and settings\Terry\Cookies. I now need to find a convenient way to do it.

Terry Porritt
17-11-2003, 03:09 PM
Ive also forgotten to say my drive is formatted fat32, so NTFS permissions are not available for what thats worth. That is another learning curve to go through!

Graham L
17-11-2003, 04:27 PM
You should have stuck with W3.11 and DOS 6.22, Terry. Much easier. :D

Terry Porritt
17-11-2003, 04:53 PM
Yes I should have Graham, this is all like a foreign language to me :)

But here we are, here is a simple way of deleting index.dat, cribbed from the exp.cmd referenced in the site above.

cd %homedrive%%homepath%
del /s /q index.dat

That pasted into notepad and called index.cmd, and put into the startup folder as the reference above quotes for exp.cmd, appears to work as I want :)

I havent much idea what homedrive and homepath mean only that it must refer to c:\ and to 'documents'.

Perhaps others may like to try this and let me know how it goes for them.

Graham L
17-11-2003, 05:33 PM
%homedrive%, etc, will be environment variables. Try ECHO %homedrive%, or even the good old SET command. :D I bet they've had to put most of DOS in there ... because command line stuff works, and you can't get a GUI working without using stuff that works. B-)

Terry Porritt
17-11-2003, 06:29 PM
Exactly right Graham, in fact we're both right :)
echo %homedrive% returns C:

and echo %homepath% returns \Documents and Settings\Terry

Fire-and-Ice
17-11-2003, 07:36 PM
Right, well I have to admire your perseverance on this one Terry but I have to admit defeat and am now out of this game. Nothing at all works here no matter what variation I try. I'll bookmark this thread however and the next time this box gets a format will try again because I suspect that there is something putting sticks in the works.

Incidentally are you running Win XP Pro or home? Wouldn't have thought it would make any difference but it's Win XP home here.

agent
17-11-2003, 08:33 PM
Just a few corrections:

You can save two system variables by using %userprofile%. This gives the entire path to your profile directory, not use /Documents and Settings/user. However, it will limit your batch to only deleting the index.dat files in your profile.

And, to my knowledge, the exported registry value that held a value of something like 'C:\\Documents and Settings' actually requires the double backslash. So give it a try with that double backslash, those of you who tried it with a single one.

agent
17-11-2003, 08:40 PM
Oh, can someone please remind me what's actually stored in the index.dat files so I can consider trying this?

I did know, but I've forgotten... :D *ignorance is bliss*

Terry Porritt
17-11-2003, 08:45 PM
Thanks agent. After some fidlling around earlier on I rechecked exporting a registry entry and it does make a double back slash. I dont seem to remember it doing this in win98, but perhaps it did?

I think I get your meaning about using %userprofile% , and the batch file does only delete the index.dat in my profile as you say. What Im trying to get is a global index.dat delete.

Terry Porritt
17-11-2003, 08:49 PM
Just saw your second post agent.
Basically index.dat stores history of sites visited, and cookies stored in the Cookies folder etc.
I still havent really fathomed the various folders that contain virtually the same things, like several cookie folders with their own index.dat.

Terry Porritt
17-11-2003, 08:51 PM
Oh dear, forgot Fire and Ice, Im running XP Pro SP1.

Barnabas
17-11-2003, 10:36 PM
Heres another tricky way of deleting the index.dat file. It works in Win2k but Im not sure about XP.
Start up a Dos window and navigate to the director where the index file is stored.
Now Ctrl Alt Del and end task explorer. Then flick back to your dos window and hey presto you should be able to delete that dirty index.dat file.
Now close your dos window and start up a new instance of explorer and you're away.
Does someone want to try this in XP and see if it works?

agent
17-11-2003, 10:49 PM
Works in XP too, but you do have to close every open window first.

-=JM=-
17-11-2003, 11:11 PM
I don't use IE and find my index.dat to be very boring. :D

Terry Porritt
18-11-2003, 10:47 AM
Thanks Barnabas for that tip. It works in XP too, but also if del /s /q "C:\documents and settings\index.dat" is used to delete, then all three index.dat are deleted in the user profile, the extra switches in delete command are quite useful.

mark.p
18-11-2003, 12:05 PM
If really want a usefull cli for Doze why not try Cgywin-http://www.cygwin.com/? Lots and lots of commands/usefull switches. XPs default cli is boooooring in compared to it.

Scouse
18-11-2003, 01:05 PM
Terry I'm a late arrival on this thread. Tell me again why you want to get rid of this folder/file? I too run XP Pro and might have a dabble with it if the outcome is worthwhile.

agent
18-11-2003, 01:25 PM
Yes, Cygwin is a very darned useful command shell port.

Only grudge I have is that it takes so long to download even a relatively small amount of the packages (mainly because 'relatively small' isn't that small compared to the entire range of packages) on dial-up.

Still haven't figured out how to get Apache running in it either, let alone finding the manual for fetchmail :D

PoWa
18-11-2003, 01:41 PM
> Thanks Barnabas for that tip. It works in XP too, but also if del /s /q "C:\documents and settings\index.dat" is used to delete, then all three index.dat are deleted in the user profile, the extra switches in delete command are quite useful.

Yup that works. Now is there a command that can be used inside the cmd prompt to kill the explorer process?? I thought of 'net stop explorer.exe' but that obviously doesn't work. So if we can come up with a command that shuts down explorer, deletes all the index.dats and then restarts explorer we can put all that into a batch file.

-=JM=-
18-11-2003, 03:08 PM
When explorer gets restarted you may lose some systray icons or lose the order of them atleast.

agent
18-11-2003, 03:16 PM
Yes, that's why I'm not a fan of using the 'kill explorer' method. Tried it myself, but I turned my system off for the night soon after.

Terry Porritt
18-11-2003, 06:01 PM
Well Scouse, there is no real reason I want to get rid of index.dat at this stage. Ive just installed XP Pro, and have become aware of all the dos-like command line parameters or commands.

So deleting index.dats which can get large in the course of time seemed like a good idea to start learning something new and start delving below the XP GUI. Have to admit Im blundering about a bit.

In win98 one technique was to make a dos batch file calling up the directories containing index.dat, and delete them from a boot floppy.

I suppose exactly the same can be done in XP from a Win9x boot floppy if the drive is formatted fat32.

My original scheme seemed to work, now Im not so sure, something has gone funny, but the later ideas work ok.

Scouse
18-11-2003, 10:12 PM
Thanks for the background. For a wee while I had thought I was missing out on something........

Terry Porritt
18-11-2003, 10:39 PM
The problem with index.dat files is that they have been cunningly designed by Microsoft to be difficult to find and difficult to delete, not only that but are also designed to continuously grow in size, never get smaller.

Left unchecked they will grow and grow and they contain details of every website you have ever visited and details of every cookie you have ever received, notwithstanding deleting Temporary Internet Files or Cookies.

For the paranoic, it is not difficult to imagine MS gathering all this info via, say, Windows Update.

These files have been like this ever since win 95 and IE, it has to be deliberate as they have had all the time in the world to make windows able to delete them with a click of the mouse.

Barnabas
19-11-2003, 11:04 AM
I can't figure out a way to stop the explorer service from cmd prompt. Good idea though to put it in a batch file although I gave up on batch files about a month ago while trying to write nested for loops.

If anyone else knows how to end the service in dos then please...share the love :-)
B.