Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hey all I'm new here and new to batch files. I have been writing and studying batch files for about 2 weeks and have made a batch file that will delete my Temp files on boot up, here it is:
echo y | DEL c:\windows\temp\*.*
echo y | DEL C:\DOCUME~1\Mookers\LOCALS~1\Temp\*.*
:endThis works great but now I want to go one step further and delete everything from my temp internet files except the cookies.Here is what I have so far:
echo y | DEL C:\DOCUME~1\Mookers\LOCALS~1\TEMPOR~1\*.gifI'll add more line with more file extensions once I get it to work.
Here is the error I get from that line:
Could not find C:\DOCUME~1\Mookers\LOCALS~1\TEMPOR~1\*.gifI know this is the Dir because i'm looking right at it. Is there a special way to do this??
Thanks
Mookers

First of all why do you use the cumbersome format "Echo y | Del..." when it is far more friendly to type
Del /Q C:\Windows\Temp\*.*
where /Q means "delete unconditionally"?
Be confident with the /? switch (on-line help).
Now to fit your trouble, the directory is probably "hidden" so it can't be accessed.
To work around you have to change its attributes using the Attrib command, e.g.
Attrib C:\DOCUME~1\Mookers\LOCALS~1\TEMPOR~1 -H
then issue the Del command and eventually restore the original attribute
Attrib C:\DOCUME~1\Mookers\LOCALS~1\TEMPOR~1 +H
That should work to solve your problem.

Thanks for the help. :)
I didnt know about the /Q command , but I'll give it a try in a few min. I'm still green with batch files , but they seem to be not to bad to manage once you get it down.Thanks Again

Ok I just tried it. I put the following:
Attrib
C:\DOCUME~1\Mookers\LOCALS~1\TEMPOR~1 -H
Del /Q C:\DOCUME~1\Mookers\LOCALS~1\TEMPOR~1\*.gif
Attrib C:\DOCUME~1\Mookers\LOCALS~1\TEMPOR~1 +HAnd I got pretty much the same errors. It says Could not find C:\DOCUME~1\Mookers\LOCALS~1\TEMPOR~1\*.gif
and also says:
Not resteeing system file - C:\DOCUME~1\Mookers\LOCALS~1\TEMPORARY INTERNET FILESIt says this when it first runs the attrib command and when it tries to finish with the attrib command.
Any Ideas?? I have no Idea because im still so new to this :(

Try to change the "system" attribute too, i.e. add at the end of the Attrib command the -s (and then +s) switch )Attrib ... -s -h).
That should work.

Ok So you mean to put it like this right?
Attrib
C:\DOCUME~1\Mookers\LOCALS~1\TEMPOR~1 -S
Del /Q C:\DOCUME~1\Mookers\LOCALS~1\TEMPOR~1\*.gif
Attrib C:\DOCUME~1\Mookers\LOCALS~1\TEMPOR~1 +SThis got rid of the "Not resetting" error I had, but it still can't find the Dir for C:\DOCUME~1\Mookers\LOCALS~1\TEMPOR~1\*.gif
Sorry for buggin about this. I know it's prolly something easy. I just need to see it run once, then I'll beable to make varitions of it for differnt things and learn what and how it's doing it.

Don't know about your XP system but on my 98 box there is another layer of random named subfolders under IE5.Content which is under the tempor~1 folder. You won't be able to name the random folders in a batch file as they will change from time to time. This way on purpose.
Deletion has to take place from the random named folders because what you see when sitting at Temporary Internet Files folders is but a mirage due to desktop.ini file functions and Windows software.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/programmersguide/shell_basics/shell_basics_extending/custom.asp
It seems ie was written to prevent exactly what you want to do here and so I wonder what success you'll ever truly have?I question the wisdom of what you even want to do here. As in why - when it's easier to delete the files from the Internet Options menu? This method also does not delete the cookies if you didn't know that. You can set ie to empty the TIF folder on closing also (advanced tab).
I also wonder if you were never warned to NOT delete temp files at boot up? You didn't know that some installations of software use the temp folder to store files needed at the next boot up for completion of installation? If you come along and delete them just before they are needed, you've just ruined the installation and you'll never be able to figure out why you can't install X. It(X) may also not be uninstallable at that point too.
I appreciate your zeal for batch but please don't re-invent the wheel before my just purchased tires are at least half worn out.

Yes, I think deleting temp files can easily 'trip up' windowas.
But for general batch simplicity, if you have some beserk path, which you often will, use something like this:
subst K: "C:\Documents and Settings\Administrator\Application Data\Mozilla\Profiles\default\m3mxf621.slt"
[That's ONE line.]Then you can have neater bat lines, like:
del /q k:*.*
I applaud your efforts, but winders tends to topple over when you disappear stuff by stealth.
M2

Why did not you read with attention my post # 4 ? I suggested to ADD the -s/+s switch NOT to replace the -h/+h. So the command must be
Attrib ... -s -h
and then
Attrib ... +s +h
Care must be the first effort in scripting/programming and, by the way, I agree with guys warning you as doing a dangerous job, especially regarding your knowledge of system internal.

This page is much wider than the screen.
Same thing happens with maybe 1 of of a few hundred msgs.
Why?
M2

Wow! Thatnks for all the info guys!!! I'm learning a great deal here :) The onlt reason I wanted this batch file to clean up the folders was because of the 30 PC Machines I have to do this to every so offten. I find it a pain to walk around and go to internet options on each machine. This takes a full morning and sometimes a whole day of deleting files. The users are not allowed to do it , and in most cases i'm sure they don't know how to empty the temp internet files. All I needed to empty was the files in the temp internet files folder, not the cookies. If changing to a browser like firefox will let me do this easier then I'll do that and ask for help here to figure it out.
As for the Tepm folder, I didnt know the files were inportant. I figured that since the folder is called "Temp" it would be ok to delete the files, lol. I noticed that the folder on one machine here had close to 1 GIG of stuff in it and I just wanted to clean it up. Guess I'll forget about the Tepm folder and try to get the Tepm internet folder working instead.
Thanks for the help guys!!!
Any suggestions for a browser I can use that will allow me to run a batch to clean up the files? Or maybe a browser that has this feature built it :)

Hey I just set my internet explorer to clean out when I close it and it works great. I keept all the cookies and all the other files are gone!! Thanks for the tip man!!! WooHoo!!! Have any of you ever used the Cookiewall program by analog X ? I use this on all the machines here at work and it works great. I can keep all the good cookies and tell it to throw away all the bad ones :) So now with the internet explorer cleaning out the folder on its own, and the cookiewall program running, I won't have to worry about wasted space so much any more :)
Thanks again all!!
I still want to learn batch files though, lol.

In any case Mozilla. FireFox are better broesers.
But as many have said, 'force deleting' may screw up winders.
How about: c:> right click > properties > disk cleanup
HTH
M2

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |