How to Clean Computer Using CMD
In this part, we will show you how to use different commands to clean different files. Firstly, you need to open Command Prompt with admin rights.
Step 1: In Windows 10/11, type cmd into the search box.
Step 2: Click Run as administrator from the popup to open the CMD window.
Next, perform the cleaning operation via some clean commands in CMD.
Run Cleanmgr to Clean Unwanted Files
Cleanmgr is an automating disk cleanup tool in Windows operating system. It can search and analyze your hard drive to find files that are no longer needed and delete them automatically to free up disk space on the hard drive.
By configuring cleanmgr.exe with command-line switches, temp setup files, Internet files, downloaded programs files, old chkdsk files, Recycle Bin files and more can be deleted. You can use the Scheduled Tasks tool to schedule the task to run at a specific time.
Let’s see how to clean computer using CMD – Cleanmgr.
Step 1: Open CMD with admin rights.
Step 2: Type Cleanmgr into the CMD window and press Enter.
Step 3: A small window pops up to ask you to choose the drive you want to clean up. Then, click OK.
Step 4: Check the items you want to delete and then this tool will delete them to free up disk space.
Cleanmgr – the command for disk cleanup, offers multiple parameters dedicated to specific functions, and let’s see examples.
1. Cleanmgr /sageset
This command for disk cleanup helps to directly skip the selection of the drive and redirect you to the Disk Cleanup Settings window to choose the items you want Disk Cleanup to automatically clean up during its scheduled run times.
2. Cleanmgr /sagerun
This command doesn’t choose the category and helps to automate the disk-cleaning process.
3. Cleanmgr /lowdisk
This command is very useful when the hard drive meets low disk space. When running this command, all checkboxes of file categories will be selected by default. The command example is like – cleanmgr /lowdisk/dc. Here c refers to the drive letter.
The command – cleanmgr /verylowdisk/dc helps to delete all junk files quickly without the user prompt.
Run CMD to Temp Files
Windows can create temporary files for temporary use and they are called Temp. During the operation of a program, these files are generated for backup purposes and store information in a short time. They are primarily to store, transfer data and recover lost data.
Temp files won’t take up much disk space and play an important role in the smooth functioning of your system. After finishing tasks, the system will automatically remove them from the temporary folders. It is safe only when temp files are not used by any apps. Or else, Windows will block you from deleting them with the result – failing app tasks.
For temporary files created by Windows operating system, the storage path is %system%/windows/temp. While for the temporary files created by the users, the path is C:\Users\username\AppData\Local\Temp.
If you want to view temporary files, run this command – %SystemRoot%\explorer.exe %temp%\. This can open the Temp folder in File Explorer. Just press Ctrl + A to choose all the files and delete them. Or run the command – del %temp%\*.* /s /q to delete them. The CMD tool can automatically skip any files that are currently in use but delete the rest files.
Defragment Your Hard Drive via CMD
When talking about “clean computer using CMD”, there is one thing you should think of is the disk defrag. Although fragmentation on the hard drive (only for the traditional hard disk) is a natural occurrence, it may lead to PC performance issues, for example, the access and write speed can be impacted, slowing down the system.
Defrag can reorganize fragmented data in the hard drive so that your PC can access files from the hard drive. You don’t need to defragment your SSDs since this may destroy them or reduce their lifespan. Only defragment your HDDs by following the clean command in CMD – defrag driver letter:.
Step 1: Open Command Prompt as an administrator.
Step 2: Type defrag c: into the CMD window and press Enter. Here replace c: with your drive letter
Delete Prefetch Files Using Command Prompt
When you use a program first, Windows operating system will create prefetch files that can work as a cache later. That is, prefetch files are used to store information regarding software activity, including how many times the software has run, when the app was running and associated files used by the software.
These prefetch files are text files with a .pf extension and they are very useful in the quicker loading of programs. But they could take up much disk space. And if you run into app bugs or lags, you can choose to delete these files. Deleting them is harmless and Windows will create prefetch files again the next time you open programs on your computer.
See how to clean computer using CMD by deleting prefetch files:
Step 1: Open CMD with admin permissions in Windows.
Step 2: Type %SystemRoot%\explorer.exe C:\Windows\prefetch\ to the Command Prompt window and press Enter to check the prefetch files. This can open the Prefetch folder in File Explorer.
Step 3: Type del C:\Windows\prefetch\*.*/s/q and press Enter to delete these prefetch files. Alternatively, you can directly delete the Prefetch folder from Windows Explorer.
Clear Cache Memory in Windows
Cache files can dramatically improve performance, availability, and scalability, and they can bring the ability to serve data quickly and faster response times. However, if cache files go wrong, data fetching issues, glitches, or even crashes can happen. A common solution is to clear cache files regularly.
You can choose to clear the DNS cache and Windows store cache. If something goes wrong during the cache-clearing process, the Windows system will tell you.
To clear the DNS cache, execute the command – ipconfig/flushDNS in the CMD window. To clear the Windows store cache, execute this command – wsreset.exe.
DISM Windows Image Cleanup
Deployment Image Servicing and Management (DISM) is a useful command tool that can help to service and prepare system images. You can use DISM to manage a Windows image (.wim) and virtual hard disk (.vhd). It is used for Windows Recovery Environment (WinRE), Windows PE, and Windows Setup. Via the DISM tool, you can fix many system errors including update errors, boot errors, and more.
To check if there is any corruption, run DISM /online /Cleanup-Image /CheckHealth in the CMD window.
To scan the Windows image, execute this command – DISM /Online /Cleanup-Image /ScanHealth.
To fix Windows images, type DISM /Online /Cleanup-Image /RestoreHealth into the CMD window and press Enter.
Cleanmgr /sagerun | automate
cleanmgr /lowdisk/dc
cleanmgr /verylowdisk/dc | automate
ipconfig/flushDNS
Post a Comment