How to more easily empty temp directory?

  • Thread starter Thread starter wee
  • Start date Start date
W

wee

My c:\windows\temp directory keeps filling with temp files. I can and
do manually delete them, but how can I delete them more easily?
Is there an option somewhere?
In W98 I can make a batch file with:

deltree c:\windows\temp /Y
md c:\windows\temp

But how to do it in XP?

Thanks
 
Recommend you use XP's Disk Cleanup utility. You can even set it to run
on a scheduled basis if you like.

%SystemRoot%\System32\cleanmgr.exe

Hope this is useful to you. Let us know.

rms
 
Sadly this program does not seem to be 100% successful. I've just tried it
and it left some files with yesterdays date and several subfolders.

Peter
 
My c:\windows\temp directory keeps filling with temp files. I can and
do manually delete them, but how can I delete them more easily?
Is there an option somewhere?
In W98 I can make a batch file with:

deltree c:\windows\temp /Y
md c:\windows\temp

But how to do it in XP?

Do a similar thing, using the lines

@Echo off
CD /D C:\WINDOWS\TEMP
DEL /Q /F *.* >NUL
FOR /D %%i in (*) DO RMDIR /S /Q "%%i" >NUL
Exit

which will change to the directory, do a delete of everything in it in
Quiet mode (/Q, so not asking questions), including read only files /F
and sending its output to the null black hole. The RMDIR line will
clear out subdirectories - do it this way rather than the alternative of
using a /S switch in the DEL, because it won't get in difficulty if
something has made folder there already with files active in it

You might usefully include a set

CD %HOMEPATH%\Local settings\Temp
DEL /Q /F *.* >NUL
FOR /D %%i in (*) DO RMDIR /S /Q "%%i" >NUL

before the exit, to clear the temp folder in your Profile, which is one
a lot of things will be using

Then right click on Start, take Open, Open up Programs - Startup and put
the file in there to run automatically
 
@Echo off
CD /D C:\WINDOWS\TEMP
DEL /Q /F *.* >NUL
FOR /D %%i in (*) DO RMDIR /S /Q "%%i" >NUL
Exit

Tried it - it worked fine. I DO NOT PLAN TO USE IT EXCEPT AT
SHUTDOWN.

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top