Deleting Temporary Files with a Batch File and Running it Silently with Windows Scheduler
Outdated phrases Outdated phrases
13 subscribers
91 views
0

 Published On Jun 30, 2024

how to delete temporary files, %temp% files, prefect files, recent files, and clean the Recycle Bin using a batch file. We'll also set up a task in Windows Scheduler to run this batch file every hour silently, without any pop-ups.

Below are require code to do the task,

Batch File code

@echo off
echo Deleting temporary files...
del /s /q %temp%\*
del /s /q C:\Windows\Temp\*
echo Deleting prefetch files...
del /s /q C:\Windows\Prefetch\*
echo Deleting recent files...
del /s /q %userprofile%\Recent\*
echo Cleaning Recycle Bin...
PowerShell -NoProfile -Command Clear-RecycleBin -Confirm:$false
echo Done!


VBS Script code

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run chr(34) & "C:\path\to\temp_clean.bat" & Chr(34), 0
Set WshShell = Nothing

Make sure to replace C:\path\to\temp_clean.bat with the actual path to your batch file."

show more

Share/Embed