How to Clean your Windows PC using CMD (Command Prompt)

If you are using the latest version of Windows, you might know that the operating system fills up the storage very quickly. This is because we install lots of programs on our computers.

Keeping your computer free from clutter is one of the ways to improve performance and stability. By just cleaning up the junk files, you can free up tons of disk space.

Windows 10 & 11 also offer several built-in system junk cleaning utilities to free up storage space. Although it’s pretty easy to access those tools, wouldn’t it be easier to access the hidden tools via CMD?

Also read: How to Reset Windows 10/11 via CMD (Command Prompt)

How to Clean your Windows PC using CMD (Command Prompt)

This article will share some of the best methods to clean Windows PC via Command Prompt. The methods shared below are very easy to follow. So, let’s check out.

1. Defragment Hard Disk via CMD

In this method, we will defrag our hard disk via CMD. This method will clean all junk files stored on selected drives. Let’s check out.

1. First, click the Windows Start button and type in CMD. Next, right-click on the Command Promot and select Run as Administrator.

open CMD

2. On the Command Prompt, enter the command:

defrag c:

defrag c:

Important: The above command will defrag the C: Drive of your PC. Change the drive letter if you want to defrag any other drive.

3. Now, the Disk Defragment tool will scan the selected drive and remove the junk & temp files.

remove the junk & temp files

That’s it! You are done. This is how you can run the Disk Defragment tool via CMD.

2. Run Disk Cleanup Utility via CMD

In this method, we will run the built-in Disk Cleanup utility of Windows 10 to free up storage space. Follow some of the simple steps given below.

1. Click on the Windows Start button and type in CMD. Next, right-click on the Command Promot and select Run as Administrator.

Run Disk Cleanup Utility via CMD

2. Now, on the Command Prompt, type in cleanmgr and hit the Enter button.

cleanmgr

3. This will launch the Disk Cleanup utility. Select the drive you want to clean and click the Ok button.

Disk Cleanup utility

4. If you wish to skip the drive selection pop-up, enter the command:

cleanmgr /sageset

cleanmgr /sageset

You need to select the files to delete after executing the above command

5. If you wish to delete files automatically, then execute the command:

cleanmgr /sagerun

cleanmgr /sagerun

The above command will automatically scan your drives and delete junk files from your PC.

3. Clear Temporary Files Using the Command Prompt

You can also use the Command Prompt utility to clear the temporary files. Here’s how you can clear the temporary files using the Command Prompt utility on Windows.

1. Click on Windows 11 Search and type Command Prompt. Right-click on the Command Prompt and select Run as administrator.

Run as administrator

2. When the Command Prompt opens, execute the given command:

%SystemRoot%\explorer.exe %temp%\

execute the given command

3. You can use the CTRL + A function to select all files. Once selected, you can delete it. Or else, execute the command to delete all temporary files.

del %temp%\*.* /s /q

delete all temporary files

That’s it! The above command will automatically clear all temporary files stored on your computer.

So, this guide is all about how to clean your Windows 10/11 PC via Command Prompt. I hope this article helped you! Please share it with your friends also. If you have any doubts, let us know in the comment box below.

LEAVE A REPLY

Please enter your comment!
Please enter your name here