Below we will look at some ways to clean a slow computer Windows using the command line.
The disk cleanup tool and the Storage Sense function 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 search bar of Windows.
- 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:
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: to perform analysis, add exceptions, change priority, and more.
Use the Disk Cleanup Utility
Disk Cleanup is a built-in utility of Windows that will help 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.
Skip drive selection
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.
The lowdisk command, as the name implies, is useful if you do not have storage space on your hard disk. Automatically checks 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:
The Windows create 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:
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 need to be very careful with the diskpart utility. Using the wrong commands can erase your disk, and erase it completely. So we recommend that you back up 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:
Once the command is complete, type exit to close the diskpart.