Batch file to start, run,% TEMP% and delete all
looking for a way to do the following:
Start> Run> "% TEMP%> Delete All (skip any conflicts).
I still have
@echo off start %TEMP% DEL *.*
I suppose I could use the CD to access the folder, I wonder if there are any instances where it cannot delete the dialog box, I want to skip them.
Thanks for the help! Liam
del
will not cause any dialogs or messages. You have a few problems:
start
will simply open Explorer, which will be useless. You needcd
to change the working directory of your batch file (/D
, so it also works when launched from another drive):cd /D %temp%
You can also delete directories:
for /d %%D in (*) do rd /s /q "%%D"
You need to skip the question for
del
and delete the read-only files:del /f /q *
so you come:
@echo off cd /D %temp% for /d %%D in (*) do rd /s /q "%%D" del /f /q *
If you want to delete all files in the %TEMP%
folder, you can simply do this:
del %TEMP%\*.* /f /s /q
This will delete everything, any file with any extension ( *.*
) And do the same for all subfolders ( /s
) without asking for anything ( /q
), it will just do it, including read-only files ( /f
).
Hope this helps.
The following command commands are used to delete all of your temp, recent and prefetch files on your system.
Save the following code as โClear.batโ on the local system
*********START CODE************ @ECHO OFF del /s /f /q %userprofile%\Recent\*.* del /s /f /q C:\Windows\Prefetch\*.* del /s /f /q C:\Windows\Temp\*.* del /s /f /q %USERPROFILE%\appdata\local\temp\*.* /Below command to Show the folder after deleted files Explorer %userprofile%\Recent Explorer C:\Windows\Prefetch Explorer C:\Windows\Temp Explorer %USERPROFILE%\appdata\local\temp *********END CODE************
@echo off del /s /f /q %windir%\temp\*.* rd /s /q %windir%\temp md %windir%\temp del /s /f /q %windir%\Prefetch\*.* rd /s /q %windir%\Prefetch md %windir%\Prefetch del /s /f /q %windir%\system32\dllcache\*.* rd /s /q %windir%\system32\dllcache md %windir%\system32\dllcache del /s /f /q "%SysteDrive%\Temp"\*.* rd /s /q "%SysteDrive%\Temp" md "%SysteDrive%\Temp" del /s /f /q %temp%\*.* rd /s /q %temp% md %temp% del /s /f /q "%USERPROFILE%\Local Settings\History"\*.* rd /s /q "%USERPROFILE%\Local Settings\History" md "%USERPROFILE%\Local Settings\History" del /s /f /q "%USERPROFILE%\Local Settings\Temporary Internet Files"\*.* rd /s /q "%USERPROFILE%\Local Settings\Temporary Internet Files" md "%USERPROFILE%\Local Settings\Temporary Internet Files" del /s /f /q "%USERPROFILE%\Local Settings\Temp"\*.* rd /s /q "%USERPROFILE%\Local Settings\Temp" md "%USERPROFILE%\Local Settings\Temp" del /s /f /q "%USERPROFILE%\Recent"\*.* rd /s /q "%USERPROFILE%\Recent" md "%USERPROFILE%\Recent" del /s /f /q "%USERPROFILE%\Cookies"\*.* rd /s /q "%USERPROFILE%\Cookies" md "%USERPROFILE%\Cookies"
@echo off del /s /f /qc:\windows\temp\*.* rd /s /qc:\windows\temp md c:\windows\temp del /s /f /q C:\WINDOWS\Prefetch del /s /f /q %temp%\*.* rd /s /q %temp% md %temp% deltree /yc:\windows\tempor~1 deltree /yc:\windows\temp deltree /yc:\windows\tmp deltree /yc:\windows\ff*.tmp deltree /yc:\windows\history deltree /yc:\windows\cookies deltree /yc:\windows\recent deltree /yc:\windows\spool\printers del c:\WIN386.SWP cls