If you enjoy using the Command Prompt to maintain your Windows 11 PC, you can easily execute commands to clean your system. This allows you to remove junk files, temporary files, prefetch files, and even defragment your hard drive.
Windows 11 includes a built-in disk cleanup tool designed to clear system junk, temporary files, and other unnecessary items that consume resources and take up storage space. While accessing these tools is straightforward, Command Prompt enthusiasts may prefer to utilize these hidden features through CMD for a more streamlined experience.
Utilizing CMD for maintenance tasks is perfect for users who prefer a command-line interface for a cleaner, faster Windows 11 experience. Here is how to do it.
Contents
How to Use Command Prompt to Run Disk Cleanup Utility
1. First, open the Command Prompt as administrator.

2. Next type the command cleanmgr
and press Enter button.

3. This will launch the Disk Cleanup utility. Select the drive you want to clean and click the Ok button.
4. If you wish to skip the drive selection pop-up, execute the command: cleanmgr /sageset

5. If you wish to delete files automatically, then execute the command: cleanmgr /sagerun
6. The above command will automatically scan your drives and delete junk files from your PC.
How to Clear Temporary Files Using the Command Prompt?
1. Open Command Prompt as administrator.
2. Execute the given command: %SystemRoot%\explorer.exe %temp%\

3. You can use the CTRL + A function to select all files. Once selected, you can delete it.
4. Or execute the command del %temp%*.* /s /q
to delete all temporary files.
How to Delete the Prefetch Files Using the Command Prompt
1. Open Command Prompt as administrator.
2. Execute the command %SystemRoot%\explorer.exe C:\Windows\prefetch\

3. Once done, execute this command to delete the Prefetch files: del C:\Windows\prefetch*.*/s/q
How to Defrag the Hard Disk via Command Prompt
Important: Do not defrag SSD. Execute the command if your PC has HDD.
1. Open Command Prompt as administrator.
2. Type the command defrag c:
and press Enter. [Change the drive letter if you want to defrag any other drive.]
3. The Disk Defragment tool will scan the selected drive and defrag the drive.
Conclusion:
In summary, cleaning your Windows 11 PC via Command Prompt is an efficient way to remove junk files, temporary files, and prefetch data. By executing specific commands, you can optimize system performance and free up storage space. This method is ideal for users who prefer a command-line interface for maintenance tasks.
Comments (0)