deleting temp file's in DOS

Associate
Joined
8 Mar 2007
Posts
2,176
Location
between here and there
hey all,

I'm writing a simple bacth file to remove those blasted temp file's from pc every monday night.

since i only have one account that is used on this machine i can use ask it to del the files from my "C:\Documents and Settings\Tristan\Local Settings\Temp" folder.

The problem is that if i do this i still get left with a load of read only files. when i try with just del /q "C:\Documents and Settings\Tristan\Local Settings\Temp\*.*" i get acess deinded error.

I have tried using the /f switch to force delete the read only stuff but it then doesn't even give me the 'access denided' error

is there anything more powerfull than 'del' in dos??

I can remove these files by selecting them and sending to the bin, but i wanted to automate it.

cheers for your help guys;)


edit;

I've also tried deleing the temp folder alltogether and them making an new empty one in its place, but no luck. :(
 
plonk a shortcut on your desktop or maybe even in the startup folder. no need to worry about permssions then. :p

and surely even scheduled tasks can be set to run under a certain account?

i use crap cleaner myself. much better than just clearing temp files - it clears so much more. plus you can automate it once you've configured it. :D
 
thanks for the reply..

plonk a shortcut on your desktop or maybe even in the startup folder. no need to worry about permssions then.

This is an option, but tbh i'd rather not have another shortcut on my desktop.

I also entend to put this (or at least a version of this) on serval family members PC so they don't have to worry about it, (and so they don't call me and say, 'my Pc running slowly')

So really it does need to be automatic.

any ideas
 
You could you the dos 'RunAs' command.

If that doesn't work you might want to try using rmdir to remove the temp directory or use Attrib to remove the read only attribute from the files.[/QUOTE].
 
Last edited:
use scheduled tasks then.

I thought that'll be easier but.....


I set the permissions for the task, but it still wont delete the temp files from within the temp folder.

I then get a taskobject (.job) in my recycle bin.

can anyone talk me though this???

or shall i post in windows and other software?

cheers
 
well you need to test your batch file first before using scheduled tasks. now by default, even admin accounts won't have access to other user's folders in windows. that's why i said you need to explicitly set the permissions. unless you give yourself permission, you can't even browse their folders through explorer. try it.
 
sorry, i didn't explain very well.

I have only 2 user on this laptop. admin and tris. I only ever use admin.

The bacth file is very simple

Code:
@echo off

cd\
cd "C:\Documents and Settings\Administrator\Local Settings\Temp"
del /f /q *.*
pause

exit

I have tested it (by changing the folder paths and running) and it works fine.

I also set the scheduled task to run at log on so it should have the right permissions. I did use the 'runas' setting and put in computername\administrator and set the password, but i still get the same result.

:confused:
 
what's the point of using the scheduled task at logon? just put the shortcut to the batch file in the startup folder (or even hide it in the registry).

even better, use ccleaner as i mentioned above. it has an /auto command line switch so the user won't even see it. as well as clearing user temp files, it does the c:\windows\temp folder as well. it can do IE/firefox/opera temp files (fully configurable - you might want to keep cookies for instance) as well as many other apps. just seems pointless using such a basic script when there is a far easier method. :)

edit: here's a screenshot....



now just run it with

ccleaner /auto

you won't even see it. :)
 
Last edited:
cheers guys.

ccleaner will do the job real nice like...

but i've answered my own question.

I had to use RMDIR (the XP prompt replacment for DELTREE) to remove everything in it.

I also had to unhide the local settings folder for my user.

All good. cheers.

:)
 
Back
Top Bottom