INTERNET

How to Clean Your Windows PC Using Command Prompt

0

Keeping your computer free from clutter can help improve performance and free up tons of storage space. Windows comes with several built-in system-cleanup utilities, such as the Disk Cleanup tool. However, one lesser-known way to clean your computer is via the Command Prompt.

Here are a few ways to clean up a slow Windows computer using Command Prompt.

Why Clean Up Your Computer Using Command Prompt?

Command Prompt is a built-in command processor available on almost all Windows versions since Windows 3.1. While the graphical user interface is handy for most people, some may prefer the Command Prompt to perform several tasks for its efficiency and performance benefits.

If you are new to Microsoft’s popular command processor, check out our beginner’s guide to the Windows Command Prompt.

The Disk Cleanup tool and the Storage Sense feature in Windows 10 make it fairly easy to clean up your computer. If any unwanted files remain, you can remove them manually by, for example, clearing your temp folder. You can speed up this process with the help of commands to access the Disk Defragmenter, diskpart, and the Disk Cleanup tool.

Commands to Clean Your Computer Using CMD

Below is the list of commands to launch the disk cleanup utility, clean temporary files, memory cache, and more.

Some of these commands may require you to open Command Prompt as administrator. Here’s how to do it.

  1. Type cmd in the Windows search bar.
  2. Right-click on Command Prompt.
  3. Select Run as administrator.

How to Defragment Hard Disk With Command Prompt?

While disk fragmentation on traditional hard disks is a natural occurrence, it can cause performance issues. It affects the access and write speed of your disk, making your system slow.

The Windows Command Prompt in the process of defragmentation, showing volume information and the expected results

Defragmentation rearranges fragmented data to help your disks work more efficiently. You don’t need to defragment your SSD drives, but if you use a mechanical drive, here’s how to defragment the hard disk with a command.

  1. Open the Command Prompt as administrator.
  2. In the Command Prompt, type the following command and hit enter:
    defrag c:
  3. In the above command, c: is the drive that you want to defrag. Change the drive letter if you want to defrag another drive.

You can run the defrag command with optional switches. This Microsoft Documentation offers more insight into using different syntax with the defrag command to perform analysis, add exceptions, change priority, and more.

How to Use the Disk Cleanup Utility via Command Prompt

The Windows Disk Cleanup program, a GUI app launched from a command prompt

Disk Cleanup is a built-in Windows utility to help you free up space on your computer’s hard drive. It can clean up downloads, temporary internet files, recycle bin, and even system files.

You can use the Command Prompt to launch Disk Cleanup and perform some automated cleanup tasks directly. Here is how to use the tool and command-line switches supported.

Basic File Deletion

You can use the cleanmgr command to launch the Disk Cleanup tool using Command Prompt. To use it:

  1. Open Command Prompt, type cleanmgr, and hit Enter.
  2. In the Drive Selection window, select the drive you want to clean up and click OK.
  3. Next, in the Disk Cleanup window, select all the files you want to delete and click OK.
  4. Finally, click on Delete Files to confirm the action.

Skipping Drive Selection

cleanmgr /sageset

Executing this command skips the drive selection step and shows the Disk Cleanup settings window. From here, you can select the files to delete.

Delete Files Automatically

If you would rather let the Disk Cleanup utility decide what files to delete, use the cleanmgr /sagerun variant. Upon execution, it will scan your drives and delete junk files from your system.

cleanmgr /sagerun

Optimize for Low Space

The lowdisk switch, as the name suggests, is useful if you are running low on storage space on your hard disk. When executed, it automatically checks all the files categories by default.

When using this form of the command, enter the drive letter for the partition to free up space. The command will look something like this:

cleanmgr /lowdisk /d

When executed, Disk Cleanup will open with all junk files categories selected from the D: drive.

To delete all junk files quickly, without the user prompt, use the following command instead:

cleanmgr /verylowdisk /d

How to Clear Temporary Files Using Command Prompt?

Windows creates temporary files for momentary use. Temp files rarely occupy a large space on your hard drive and are essential for the smooth functioning of your system. When the task is complete, your system should automatically discard them from the temporary folders.

The Disk Cleanup tool cleans temporary files that are older than seven days. But if you have to clean the temp folder frequently, you can do it manually or using the Command Prompt.

The Windows Command Prompt with the del command in progress, showing some individual files that cannot be deleted

To view temporary files, enter the following command in Command Prompt:

%SystemRoot%\explorer.exe %temp%\

You can delete these files manually (Ctrl + A > Delete) from the File Explorer or use the following command to delete temp files:

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

Command Prompt will automatically skip any file that is currently in use, but it will delete the rest.

Cleaning a Hard Disk Using Diskpart

If you want to wipe clean an entire disk, you can use the diskpart utility. Diskpart is a Windows command-line utility with support for over 38 commands for different functions.

To wipe clean a disk, you can use diskpart’s clean command. Upon execution, it deletes all the data and converts the disk into unallocated space.

The Windows command prompt running the DiskPart program, with available volumes listed

Exercise caution when using the diskpart utility. Using incorrect objects can cost you all of your data, and you may not be able to recover any of it at all. Therefore, we recommended you create a backup of your important system data before using the diskpart tool.

To clean a disk:

  1. Type diskpart In the Command Prompt and hit enter.
  2. Next, type list disk to view all the installed disks on your system
  3. Select the disk you want to wipe clean. For example:
    Select disk 0
  4. If the disk status shows offline, type online disk and hit enter.
  5. To wipe clean your disk, type the following command and hit enter:
    Clean all
  6. Once completed, type exit to close diskpart.

Keep Your Computer Clean From Junk Files Using Command Prompt

You can use the Command Prompt to perform various advanced actions, including removing junk files from your computer. While you can use the GUI-based Disk Cleanup tool, Command Prompt makes it easy to clean up individual category files and wipe clean disks.

admin

Which OnePlus Phones Will Get the Android 12 Update?

Previous article

Google’s New Nest Cameras and Doorbell Pack More Features at a Lower Price Tag

Next article

You may also like

Comments

Leave a reply

Your email address will not be published. Required fields are marked *

More in INTERNET

Login/Sign up