Clean Windows from the command line

Below we will look at some ways to clean up a slow computer using the command line.

Command Prompt is a built-in command editor available in almost all versions of Windows from Windows 3.1 onwards.

command

The Disk Cleanup tool and Storage Sense feature in Windows 10 make it quite easy to clean your computer. If unwanted files remain, you can manually remove them, for example, by deleting the temp folder.

However, you can speed up this process with the help of commands to access Disk Defragmenter and the Disk Cleanup tool.

Some of the commands you will see below may require you to open the Command Prompt as an administrator:

  • Type cmd in the Windows search bar.
  • Right-click the black command line icon and select Run as Administrator.

Hard Disk Defragmenter:

Disk fragmentation on traditional hard drives can cause performance problems. It affects the speed of access and burning of your disk, making your system slower.

Disk Defragmenter rearranges fragmented data to help your disks work more efficiently. You do not need to rebuild the SSDs, but if you are using a mechanical disk, you can use the following command.

Open the command prompt as an administrator, type the command, and press enter:

defrag c:

C: is the drive you want to rebuild. Change its letter if you want to rebuild on another disc.

To view all discs type

wmic logicaldisk get name

You can run the defrag command with switches. Microsoft has one auxiliary article to use a different syntax with the defrag command: for analysis, add exceptions, change priority and more.

Use the Disk Cleanup Utility

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

Use the command cleanmgr to start the Disk Cleanup tool using the command prompt. To use it:

Open the command prompt, type cleanmgr and press Enter.
In the Drive Select window, select the drive you want to clean and click OK.
Then, in the Disk Cleanup window, select all the files you want to delete and click OK.
Finally, click Delete Files.

Failure of disk drive

cleanmgr /sageset

This command skips the disk selection step and displays the Disk Cleanup settings window. So you can immediately select the files you want to delete.

If you want the Disk Cleanup utility to decide which files to delete, use the cleanmgr / sagerun command. It will scan your disks and delete unwanted files from your system.

cleanmgr /sagerun

Space optimization

The lowdisk command, as the , is useful if you are short on hard drive storage. Automatically scans all file categories by default.

If you use this form in a command, you will also need the drive letter to free up space on that partition. The command will look something like this:

cleanmgr /lowdisk /c

Disk Cleanup will scan for all categories of junk files on drive C:

To quickly delete all unwanted files without prompting the user, use the following command:

cleanmgr /verylowdisk /c

Clear temporary files:

Windows creates temporary files. Temp files usually do not take up much space on your hard drive and are essential for the smooth running of your system.

The Disk Cleanup tool clears temporary files that are older than seven days.

To display the temporary files, type the following command:

%SystemRoot%\explorer.exe %temp%\

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

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

The command prompt will automatically skip any file currently in use, and will delete everything else.

Hard Disk Cleanup using Diskpart

If you want to clean the entire disk, you can use the diskpart utility. Diskpart supports more than 38 commands for different functions.

Caution: You should be very careful with the diskpart utility. Using the wrong commands can wipe your drive, and wipe it completely. So we recommended making a copy of your important system data before using the tool.

To clean a disc:

Type diskpart At the command prompt and press enter.
Then type list disk to see all the disks installed on your system
Select the disk you want to clean (wipe). For example:

Select disk 1

If the disk status is displayed offline, type online disk and press enter.
To clear your disk, type the following command and press enter:

Clean all

Once the command is complete, type exit to close the diskpart.

iGuRu.gr The Best Technology Site in Greecefgns

every publication, directly to your inbox

Join the 2.082 registrants.
command prompt, windows, disk cleanup, iguru, iguru.gr

Written by giorgos

George still wonders what he's doing here ...

Leave a reply

Your email address is not published. Required fields are mentioned with *

Your message will not be published if:
1. Contains insulting, defamatory, racist, offensive or inappropriate comments.
2. Causes harm to minors.
3. It interferes with the privacy and individual and social rights of other users.
4. Advertises products or services or websites.
5. Contains personal information (address, phone, etc.).