Writing a Batch File

I need to write a batch file that deletes everything that resides in C:\Windows\Temp without prompting for an answer. I have tried adding
deltree /y C:\Windows\Temp then
mkdir C:\Windows\Temp to a batch file then running it. This seems to work but i have to re-boot my system because when i hit certain keys explorer windows pop up and various other strange things also. Any ideas?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


You can add this to Autoexec.bat to clear out the .TMP files automatically at boot,or just execute it manually.
Everything seems to be fine, tried it on my computer.  What kind of strange things do you get?
try this out

put this in your bat file
Echo y|del c:\windows\temp\*.*

This is your Answer.....
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

dj_hixxxyAuthor Commented:
I tried this but got access denied.
dj_hixxxyAuthor Commented:
craig i tried this & this just echos the command to the screen & nothing gets deleted from the temp file
dj_hixxxyAuthor Commented:
boom23, if i press "e" key explorer pops up, no other keys work therefore i have to re-boot
in the batch file make sure you do not have @echo off
It seems u are running the batch file being in Windows.
Some *.tmp files may be opened while you're trying to delete, so it will display "Access denied".

So better you call your batch file from Autoexec.bat by adding

CALL  <path/Batchfilename>
(Specify the whole path with the file  name )

So now it will remove all *.tmp files
while booting itself. And no need for u to do manually.

There is also another way to do this
If you dont want it to be run on each booting.  You can restart windows on Dos Mode and very well run the Batchfile from Dos prompt.

But I'll go for 1st option only.

Hope this will do.

Gook Luck



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dj_hixxxyAuthor Commented:
Insert the below command in autoexec.bat.

deltree/y c:\windows\temp

It works on my system.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows OS

From novice to tech pro — start learning today.