navigation

How to Automatically Delete Temporary Files on Windows 11

Windows 11 stores a large amount of temporary files over time, which causes some effects such as slow computer operation, unresponsive applications, etc. To free up space for your computer and speed up your computer, you should check and delete some temporary Windows folders or set up to delete temporary files on Windows 11, according to the instructions below.

 

Instructions to automatically delete temporary files Windows 11

Step 1:

First we proceed to create a command to delete temporary files from the user account's temporary folder as well as the system-wide temporary folder.

Open Notepad and enter the command below.

@echo off echo Cleaning system and user temp files. del /s /f /q %TEMP%*.* >nul 2>&1 rd /s /q %TEMP% >nul 2>&1 md %TEMP% del /s /f /q C:WindowsTemp*.* >nul 2>&1 rd /s /q C:WindowsTemp >nul 2>&1 md C:WindowsTemp echo Temporary files cleared!

 

In the save interface , enter ClearTempFiles.bat in File name and press Save.

Step 2:

Then the user opens Task Scheduler and clicks Create Basic Task to create a new task.

 

At Name we enter Clear Temporary Files then click Next to continue.

Step 3:

Users select the frequency they want to delete temporary files on their computer and click Next to proceed.

 

Next select the start time that this task will take place and click Next to continue.

Step 4:

The user selects Start a Program and then clicks Next below to continue.

In the Program/Script field , click the Browse button and select the bat file you saved earlier.

 

Step 5:

Switch to the new interface, we click on Open the Properties Dialog For This Task When I click Finish and click Finish to execute.

In the new dialog box interface, select Run With Highest Privileges and click OK to complete.

Step 6:

The above script only deletes temporary files on Windows 11. If you want to delete other files, add the following extensions to the script below.

To make your script delete the contents of the Trash as well , add the following command.

PowerShell.exe -Command "Clear-RecycleBin -Force"

To clear the Windows Update cache , enter the command below.

net stop wuauserv rd /s /q C:WindowsSoftwareDistributionDownload net start wuauserv

You can delete pretech files using the following code:

del /s /f /q C:WindowsPrefetch*.* >nul 2>&1
Update 09 June 2025