How to Clean Up Your C: Drive Using PowerShell and CMD (Step-by-Step Guide)
How to Clean Up Your C: Drive Using PowerShell and CMD (Step-by-Step Guide)
Is your Windows PC running out of storage? Is your C: drive full, your laptop slow, or Windows 11 taking forever to respond?
Before thinking about reinstalling Windows or replacing your laptop, you can often recover a huge amount of storage space using built-in command-line tools.
In this guide, we’ll show you how to clean up Disk C using PowerShell and CMD, remove junk files, clear Windows update cache, and improve system performance.
Why Cleaning Your C: Drive Matters
Over time, Windows accumulates:
Temporary files
Update leftovers
Cache files
Old log files
Hibernation files
Recycle Bin junk
These can consume gigabytes of storage and slow down even fast SSD systems.
Regular maintenance can:
✅ Free up disk space
✅ Speed up Windows 11
✅ Improve boot time
✅ Reduce system errors
✅ Extend SSD lifespan
1. Check Free Space on C: Drive
Before cleaning, see how much storage is available.
Open PowerShell as Administrator and run:
Get-PSDrive C
This shows:
Total capacity
Used space
Free disk space
2. Delete Temporary Files Using CMD
Remove user temp files:
del /q/f/s %TEMP%\*
Then clear Windows temp:
del /q/f/s C:\Windows\Temp\*
This can often recover hundreds of MB or several GB.
Keywords: delete temp files Windows, clear temp files CMD
3. Clean the Prefetch Folder
del /q/f/s C:\Windows\Prefetch\*
The Prefetch folder stores startup cache. Windows rebuilds it automatically.
Useful when optimizing a slow laptop.
4. Clear Windows Update Cache
Old update files often consume massive storage.
Stop Windows Update service:
net stop wuauserv
Delete cached update files:
rd /s /q C:\Windows\SoftwareDistribution\Download
Restart service:
net start wuauserv
Keywords: clear Windows Update cache, SoftwareDistribution cleanup
5. Run Disk Cleanup From Command Line
Launch Disk Cleanup:
cleanmgr
Advanced cleanup profile:
cleanmgr /sageset:1
Select:
Temporary files
Windows Update Cleanup
Recycle Bin
Delivery Optimization files
Thumbnails
Run cleanup:
cleanmgr /sagerun:1
Excellent for freeing disk space on Windows 11.
6. Clean WinSxS Component Store
Run:
DISM /Online /Cleanup-Image /StartComponentCleanup
More aggressive cleanup:
DISM /Online /Cleanup-Image /StartComponentCleanup /ResetBase
This can free several GB.
⚠ Note: ResetBase removes rollback for old updates.
Keywords: DISM cleanup command, WinSxS cleanup Windows 11
7. Disable Hibernation and Delete Hiberfil.sys
Hibernation can consume 8–20 GB.
Disable it:
powercfg -h off
This removes:
hiberfil.sys
Re-enable if needed:
powercfg -h on
Keywords: delete hiberfil.sys, disable hibernation Windows
8. Find Large Folders Taking Space
Use PowerShell:
Get-ChildItem C:\ -Directory |
ForEach-Object {
$size=(Get-ChildItem $_.FullName -Recurse -ErrorAction SilentlyContinue |
Measure-Object Length -Sum).Sum
[PSCustomObject]@{
Folder=$_.Name
SizeGB="{0:N2}" -f ($size/1GB)
}
} | Sort SizeGB -Descending
This helps identify storage hogs.
Perfect for diagnosing a full C: drive.
9. Empty Recycle Bin With PowerShell
Clear-RecycleBin -Force
Simple, fast, effective.
10. Delete Old Windows Log Files
del /q/f/s C:\Windows\Logs\*
Old logs can waste surprising amounts of space.
Bonus: Quick PowerShell Temp Cleanup
Remove-Item "$env:TEMP\*" -Recurse -Force
Great one-line cleanup command.
How Much Space Can You Recover?
Typical results:
2–5 GB on maintained systems
10–20 GB on neglected laptops
30+ GB with update cleanup and hibernation removal
What NOT to Delete Manually
Avoid deleting:
❌ C:\Windows\System32
❌ C:\Program Files
❌ C:\ProgramData
❌ WinSxS manually
Removing the wrong files can damage Windows.
If Your C: Drive Is Still Full…
If cleanup doesn’t solve it, you may need:
SSD upgrade
Fresh Windows 11 installation
Larger drive migration
Professional optimization
Sometimes the real fix is hardware, not cleanup.
Final Thoughts
Learning how to clean up C drive using CMD and PowerShell is one of the best ways to maintain Windows performance.
These commands can free storage, speed up your PC, and help avoid unnecessary upgrades.
If your laptop is still slow after cleanup, consider a Windows 11 fresh install or HDD to SSD upgrade for a dramatic performance boost.

Comentarii
Trimiteți un comentariu