@echo off echo Cleaning temporary files... del /q /f /s "%TEMP%\*" > nul 2>&1 del /q /f /s "C:\Windows\Temp\*" > nul 2>&1 echo Running Disk Cleanup... cleanmgr /sagerun:1 echo Done.
To keep your system lean without manual effort, you can create a recurring task in Windows Task Scheduler using these parameters: Start a program. Program/script: cleanmgr.exe disk cleanup command line
While most users know the graphical Disk Cleanup tool ( cleanmgr.exe ), running it from the command line offers more control, automation potential, and the ability to clean system files without clicking through dialogs. @echo off echo Cleaning temporary files