Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Batch File Problems

Status
Not open for further replies.

TSSTechie

Technical User
May 21, 2003
353
GB
Hi

Is it possible to write a batch file to delete all files in a directory under the Windows directory? Whenever I try to do this I get Access Denied. [flame] I have tried it on Temporary Internet Files, Temp, Cookies, History and Quick Launch all with the same result. This is happening on all machines I try the file on.

Thanks in advance

TSSTechie

[lightsaber] May The Force Be With You [trooper] [yoda]
 
What OS are you working in? I'm assuming W98/95 since you referred to the Windows directory rather than winnt - you can use the deltree command coupled with the "/Y" switch to remove these directories, i.e. -->
deltree /y c:\windows\favori~1

Hope this is some help...
 
Hi

I'm using Win98. I don't actually want to delete the directories, just the contents of them.

Cheers

TSSTechie

[lightsaber] May The Force Be With You [trooper] [yoda]
 

In your autoexec.bat file put the following entry exactly as it appears here:

deltree /y c:\windows\temp\*.*

That will kill any files and subfolders in the \windows\temp folder. You can add additional folder names and such as you see fit.

WARNING: The deltree command is VERY powerful and you can wreck things in a hurry if you are not careful. The key component to that command is ending it with \*.* which will ONLY do that directory and if it doesn't exist it will error out and not do anything.

Good luck!

 
@echo off
cdcd c:\windows\tempor~1
attrib -h -r -s -a *.*
del. |y


Cheers,
Jim
iamcan.gif
 

Doing it my way will only delete temporary files and folders or temporary internet files/folders (should you choose to point it at said directories) and nothing you need to worry about.

Have any questions or need any clarifications, lemme know.

Cheers!

 
Are you rebooting to a dos prompt instead of just going to a dos window?
(thread615-388027 crustyoldbloke's post 10-23-02)
 
Here is a sample of what I've done to "My Kids'" autoexec.bat file. It cleans the heck outta that thing everytime he reboots:


c:\windows\command\deltree /y c:\windows\cookies\*.*
c:\windows\command\deltree /y c:\windows\temporary internet files\*.*
c:\windows\command\deltree /y c:\windows\temp\*.*
c:\windows\command\deltree /y c:\windows\history\*.*
c:\windows\command\deltree /y c:\windows\recent\*.*
c:\windows\command\deltree /y c:\windows\local settings\temporary internet files\*.*


...Mac

Humpty Dumpty was pushed!!
 
All very good ideas. I would just pint out that these are all done in DOS, now Windows. That is why you are getting the Access error. You have to do this before Windows grabs them.

Jon

There is much pleasure to be gained from useless knowledge. (Bertrand Russell)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top