Computing.Net > Forums > Programming > Batch File Help

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch File Help

Reply to Message Icon

Name: Mookers
Date: October 14, 2004 at 07:43:28 Pacific
OS: XP
CPU/Ram: Pent 4 centrino/ 1 Gig Ra
Comment:

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\*.*
:end

This 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\*.gif

I'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\*.gif

I know this is the Dir because i'm looking right at it. Is there a special way to do this??

Thanks
Mookers



Sponsored Link
Ads by Google

Response Number 1
Name: IVO
Date: October 14, 2004 at 08:16:01 Pacific
Reply:

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.


0

Response Number 2
Name: Mookers
Date: October 14, 2004 at 08:30:14 Pacific
Reply:

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


0

Response Number 3
Name: Mookers
Date: October 14, 2004 at 08:39:33 Pacific
Reply:

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 +H

And 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 FILES

It 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 :(



0

Response Number 4
Name: IVO
Date: October 14, 2004 at 08:55:51 Pacific
Reply:

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.


0

Response Number 5
Name: Mookers
Date: October 14, 2004 at 11:13:29 Pacific
Reply:

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 +S

This 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.


0

Related Posts

See More



Response Number 6
Name: melee5
Date: October 14, 2004 at 20:49:53 Pacific
Reply:

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.


0

Response Number 7
Name: Mechanix2Go
Date: October 14, 2004 at 23:34:28 Pacific
Reply:

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


0

Response Number 8
Name: IVO
Date: October 15, 2004 at 02:34:58 Pacific
Reply:

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.


0

Response Number 9
Name: Mechanix2Go
Date: October 15, 2004 at 03:41:38 Pacific
Reply:

This page is much wider than the screen.

Same thing happens with maybe 1 of of a few hundred msgs.

Why?

M2


0

Response Number 10
Name: Mookers
Date: October 15, 2004 at 06:13:21 Pacific
Reply:

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 :)


0

Response Number 11
Name: Mookers
Date: October 15, 2004 at 06:25:42 Pacific
Reply:

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.


0

Response Number 12
Name: Mechanix2Go
Date: October 15, 2004 at 07:51:03 Pacific
Reply:

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


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch File Help

batch file help www.computing.net/answers/programming/batch-file-help/13830.html

batch file help www.computing.net/answers/programming/batch-file-help/190.html

Mechanix2 - Ping Batch File Help www.computing.net/answers/programming/mechanix2-ping-batch-file-help/15252.html