Forum Discussion
ConstanceBrody
Dec 20, 2024Copper Contributor
Need current Win11 cleanup batch script and other
I'm looking for assistance in creating a batch script for Windows 11 that effectively cleans up unnecessary files and optimizes system performance.
Barbarank
Dec 26, 2024Iron Contributor
@echo off
title Windows 11 Cleanup Script
echo Cleaning up unnecessary files...
:: Delete temporary files
del /q /f "%temp%\*"
echo Deleted files in %temp%
:: Clean the Windows Temp folder
del /q /f "C:\Windows\Temp\*"
echo Deleted files in C:\Windows\Temp
:: Clear the Recycle Bin
echo Clearing Recycle Bin...
PowerShell.exe -NoProfile -Command "Clear-RecycleBin -Confirm:$false"
echo Recycle Bin cleared.
:: Clean Windows Update cache (optional)
echo Cleaning Windows Update cache...
net stop wuauserv
del /q /f "C:\Windows\SoftwareDistribution\Download\*"
net start wuauserv
echo Windows Update cache cleaned.
:: Run Disk Cleanup (optional additional cleanup method)
echo Running Disk Cleanup...
cleanmgr /sagerun:1
:: Defragmenting Disk drives (optional)
echo Defragmenting all drives...
defrag C: -w
echo Disk defragmentation completed.
echo Cleanup complete. Please restart your system if required.
pause
- Cody-HutsonJan 02, 2025Iron Contributor
Should I save it as .bat and run as admin?
- JacksonRobertsonJan 02, 2025Iron Contributor
Thanks. This script worked for me