Creating a batch file to optimize Windows 11 is a great way to handle routine maintenance in one click. Below is a script that focuses on cleaning temporary files, repairing system corruption, and resetting high-CPU processes.
π οΈ Optimization Batch Script Copy the code below into Notepad, then save the file with a .bat extension (e.g., Optimize.bat). [!IMPORTANT] You must right-click the file and select “Run as Administrator” for these commands to work. @echo off title Windows 11 Optimization Script echo Preparing to optimize your system… echo —————————————–
:: 1. Clean Temporary Files echo Cleaning system and user temporary files… del /q /f /s %temp%\* del /q /f /s C:\Windows\Temp\* del /q /f /s C:\Windows\Prefetch\* echo Done.
:: 2. Flush DNS Cache (Fixes network-related CPU spikes) echo Flushing DNS Cache… ipconfig /flushdns echo Done.
:: 3. System File Check & Repair echo Running Deployment Image Servicing and Management (DISM)… dism /online /cleanup-image /restorehealth echo Running System File Checker (SFC)… sfc /scannow echo Done.
:: 4. Restart Explorer (Refreshes Shell and reduces UI lag) echo Restarting Windows Explorer… taskkill /f /im explorer.exe start explorer.exe echo Done.
:: 5. Set Power Scheme to High Performance echo Setting Power Scheme to High Performance… powercfg /setactive 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c echo Done.
echo —————————————– echo Optimization Complete! Please restart your PC for best results. pause π Understanding the CPU Impact High CPU usage in Windows 11 is often caused by specific background services. While the batch script helps, you should also check these three common culprits: SysMain (formerly Superfetch): This service preloads apps into memory. If you use an SSD, it can sometimes cause unnecessary CPU cycles. Windows Search Indexer: If your CPU stays high for hours, it might be indexing files. Startup Apps: Overloaded startup folders are the #1 cause of “slow boots.” π Manual Quick Wins If the batch file doesn’t lower your usage enough, try these settings: Disable Startup Apps: Press Ctrl + Shift + Esc, go to the Startup apps tab, and disable everything you don’t need immediately. Transparency Effects: Go to Settings > Personalization > Colors and turn off Transparency effects. This reduces the load on the Desktop Window Manager (dwm.exe). Game Mode: Ensure Game Mode is toggled ON in Settings. It prioritizes system resources for the foreground task.