Forum Discussion
How to efficiently clean up disk space in windows 11?
1. Create Custom Scripts for Additional Cleanup
To clean up disk space in Windows 11. While Storage Sense handles many common cleanup tasks, you can extend its capabilities with scripts that:
- Delete large temporary files not covered by Storage Sense.
- Clear browser caches.
- Remove old Windows update files.
- Delete specific directories or log files.
Example: PowerShe11 Script to Delete Temp Files and Clear Cache
# Delete user temp files
Remove-Item -Path "$env:TEMP\*" -Recurse -Force -ErrorAction SilentlyContinue# Delete Windows temp files
Remove-Item -Path "C:\Windows\Temp\*" -Recurse -Force -ErrorAction SilentlyContinue# Clear browser cache (example for Chrome cache)
Remove-Item -Path "$env:LOCALAPPDATA\Google\Chrome\User Data\Default\Cache\*" -Recurse -Force -ErrorAction SilentlyContinue# Optional: Remove old Windows update files
Dism /Online /Cleanup-Image /StartComponentCleanup
Note: Always test scripts on a non-critical system first.
2. Automate Script Execution with Task Scheduler
To run your cleanup scripts automatically:
- Open Task Scheduler.
- Create a New Basic Task.
- Set trigger (e.g., weekly, daily).
- Select Start a program.
Enter:
Program/script: powershell.exe
Add arguments: -ExecutionPolicy Bypass -File "C:\Path\To\YourScript.ps1"
Finish and enable the task.
Combine Storage Sense's built-in options with your custom scripts for cleaning up disk space windows 11. Always back up important data before running cleanup scripts, especially those that delete files.