Storage Clear up commands
To clean up unnecessary files and scan for old versions of files that are not being used, you can
use several commands in Command Prompt (CMD) on Windows. Here are a few useful
commands to clean and optimize your system:
1. Run Disk Cleanup (Cleaning temporary files, system files, etc.)
You can trigger the Disk Cleanup tool from the command line to remove unnecessary files.
cleanmgr
This command opens the Disk Cleanup utility. You can choose to clean system files, temporary
files, and other unneeded data.
To clean up files automatically without manually selecting options, you can run:
cleanmgr /sagerun:1
First, you would need to configure which types of files to delete by running:
cleanmgr /sageset:1
Then, select the types of files you want to delete (like system files, temporary files, etc.).
2. Remove Windows Update Files
Sometimes, old Windows updates can take up space. You can use this command to remove
them:
del /s /q /f %windir%\SoftwareDistribution\Download\*.*
This command deletes the downloaded update files.
3. Clear Cache Files
Clear temporary cache files by running:
del /q/f/s %TEMP%\*
del /q/f/s C:\Windows\Temp\*
4. Delete Old Versions of Files (System File Checker)
If you're concerned about outdated system files, you can use the System File Checker (SFC)
tool to scan and repair missing or corrupted system files.
sfc /scannow
5. Check and Clean the Disk with CHKDSK
If you suspect there are issues with your disk, use the following command to check for errors:
chkdsk C: /f
This checks the C drive for errors and attempts to fix them.
6. Delete Windows.old Folder (Old Windows Installation)
If you've recently upgraded Windows and the previous version is still present as a Windows.old
folder, you can remove it to free up space:
rd /s /q C:\Windows.old
7. Delete System Restore Points (if not needed)
If you want to delete old system restore points to free up space, you can use the following
command:
vssadmin delete shadows /for=C: /all
This deletes all system restore points, so use it with caution.
8. Use DISM to Clean Up the System Image
If you're running Windows 8 or later, you can use the DISM command to clean up system files:
DISM /Online /Cleanup-Image /StartComponentCleanup
This will remove old versions of system files that are no longer needed.
Summary of Commands:
cleanmgr (Disk Cleanup tool)
del /q/f/s %TEMP%\* (Clear temp files)
del /q/f/s C:\Windows\Temp\* (Clear system temp files)
sfc /scannow (System File Checker)
chkdsk C: /f (Check and fix disk errors)
rd /s /q C:\Windows.old (Delete Windows.old folder)
vssadmin delete shadows /for=C: /all (Delete restore points)
DISM /Online /Cleanup-Image /StartComponentCleanup (Clean system image)
These commands will help you clean up unnecessary files and improve system performance by
removing outdated files and versions.