[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 622
  • Last Modified:

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?
0
dj_hixxxy
Asked:
dj_hixxxy
1 Solution
 
MATTCEICommented:
IF EXIST C:\WINDOWS\TEMP\*.TMP DEL C:\WINDOWS\TEMP\*.TMP

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

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

This is your Answer.....
0
[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

 
dj_hixxxyAuthor Commented:
I tried this but got access denied.
0
 
dj_hixxxyAuthor Commented:
craig i tried this & this just echos the command to the screen & nothing gets deleted from the temp file
0
 
dj_hixxxyAuthor Commented:
boom23, if i press "e" key explorer pops up, no other keys work therefore i have to re-boot
0
 
craig_capelCommented:
in the batch file make sure you do not have @echo off
0
 
rkumar121699Commented:
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

Kumar

 
0
 
dj_hixxxyAuthor Commented:
Thanxs
0
 
hongjunCommented:
Insert the below command in autoexec.bat.

deltree/y c:\windows\temp

It works on my system.

hongjun
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now