How to create a Script to clear temporary files

Configurare noua (How To)

Situatie

Backup

To automatically remove temporary files on your Windows 11 PC, you’ll create a script. This script removes the temporary files from your user account’s temporary folder as well as the system-wide temporary folder.

To do that, access Windows Search (press Windows+S), type Notepad, and launch the app. Type the following code in a new Notepad document:

@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:\Windows\Temp\*.* >nul 2>&1
rd /s /q C:\Windows\Temp >nul 2>&1
md C:\Windows\Temp

echo Temporary files cleared!

To save the script, from Notepad’s menu bar, choose File > Save As. Select the folder where you want to save the script. Click the “Save as Type” drop-down menu and choose “All Files.” Click the “File Name” field and type ClearTempFiles.bat (the bat extension indicates it’s a batch file).

Notepad's "Save As" window.

Solutie

Tip solutie

Permanent

Voteaza

(5 din 8 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?