Batch file to perform start, run, %TEMP% and delete all
The following batch commands are used to delete all your temp, recent and prefetch files on your System.
Save the following code as "Clear.bat" on your 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************
If you want to remove all the files in the %TEMP%
folder you could just do this:
del %TEMP%\*.* /f /s /q
That will remove everything, any file with any extension (*.*
) and do the same for all sub-folders (/s
), without prompting you for anything (/q
), it will just do it, including read only files (/f
).
Hope this helps.
@echo off
RD %TEMP%\. /S /Q
::pause
explorer %temp%
This batch can run from anywhere. RD stands for Remove Directory but this can remove both folders and files which available to delete.
del
won't trigger any dialogs or message boxes. You have a few problems, though:
start
will just open Explorer which would be useless. You needcd
to change the working directory of your batch file (the/D
is there so it also works when run from a different drive):cd /D %temp%
You may want to delete directories as well:
for /d %%D in (*) do rd /s /q "%%D"
You need to skip the question for
del
and remove read-only files too:del /f /q *
so you arrive at:
@echo off
cd /D %temp%
for /d %%D in (*) do rd /s /q "%%D"
del /f /q *