You can quickly clean up your hard drive on Windows 10 using the Command Prompt with the "clean" command in Diskpart to remove all partitions on the specified drive.
diskpart
select disk C
clean
Understanding CMD in Windows 10
What is CMD?
Command Prompt (CMD) is a command-line interpreter in Windows operating systems that allows users to execute commands to perform specific tasks. Unlike graphical user interfaces, CMD provides a more direct method for interacting with the system, making it a powerful tool for maintenance and troubleshooting.
Basic CMD Commands for Beginners
Before diving into cleaning the hard drive, it is essential to familiarize yourself with some commonly used CMD commands, such as:
- `dir`: Lists files and directories in a specified location.
- `cd`: Changes the current directory.
- `cls`: Clears the command screen to provide a clean workspace.

Preparing to Clean Your Hard Drive
How to Access Command Prompt
To effectively clean your hard drive, first, you need to open CMD with administrative privileges. Here’s how you can do it:
- Press Windows Key + X to open the Quick Access Menu.
- Select Command Prompt (Admin) or Windows PowerShell (Admin).
- If prompted, click Yes to allow administrative access.
Assessing Disk Space Usage
Checking Disk Usage with CMD
Before starting the cleaning process, it’s crucial to understand your current disk usage. You can check this information by executing the following command:
wmic logicaldisk get size,freespace,caption
This command will display a list of all logical drives along with their total size and available free space. Interpreting these numbers will help you decide how aggressive you want to be with your cleaning efforts.

Cleaning Your Hard Drive Using CMD
Finding and Removing Temporary Files
One common source of disk space consumption is temporary files. CMD provides an easy way to remove these files using the `del` command. To delete temporary files from the Temp folder, you can use the command below:
del /Q /F /S "C:\Windows\Temp\*"
- `/Q`: Quiet mode, does not prompt for confirmation.
- `/F`: Forces deletion of read-only files.
- `/S`: Deletes specified files from all subdirectories.
Executing this command will effectively clear off temporary files that accumulate over time.
Emptying the Recycle Bin
Cleaning out the Recycle Bin is another effective way to regain disk space. You can accomplish this using the `rd` (remove directory) command as follows:
rd /s /q C:\$Recycle.Bin
In this command:
- `/s`: Removes directories and files in the specified Recycle Bin.
- `/q`: Runs the command without further prompting for confirmation.
Using this method is efficient and saves time compared to manually emptying the Recycle Bin through Windows Explorer.
Clearing Windows Cache
Occasionally, cached files can take up significant space. You can clear these using the following command:
del /q /f /s %temp%\*
The environment variable `%temp%` points to the current user's temporary files directory. This command ensures that it deletes all files within that folder quickly and without prompting.
Additional Disk Cleanup Commands
Running Disk Cleanup via CMD
You can activate the built-in Disk Cleanup utility through CMD, which provides an easy way to remove a variety of unnecessary files. You can do this by executing:
cleanmgr /sageset:1
This command will allow you to configure which files to delete during the cleanup process. You can run the tool by just typing `cleanmgr` in CMD when you want to perform the cleaning.
Using Diskpart for Advanced Users
Diskpart is a more advanced tool for managing disks and partitions. For users who are comfortable with CMD, it can be helpful but should be used with caution. Here’s how you might access it:
diskpart
From here, you can use commands to manage disks; however, ensure you know exactly what you are doing to prevent accidental data loss.

Advanced CMD Cleaning Techniques
Utilizing Windows Management Instrumentation (WMI)
For users who want to take a more technical approach, the Windows Management Instrumentation (WMI) allows you to delete specific processes or applications. For example, if you identify a program that is running and unnecessarily consuming resources, you can terminate it with:
wmic process where name="ProcessName" delete
Just replace `"ProcessName"` with the actual name of the process you wish to terminate.

Automating Cleanup with Batch Files
Creating a Batch Script
To simplify your cleaning tasks, consider creating a batch script. Here’s a sample script that combines multiple cleaning commands:
@echo off
echo Cleaning Temporary Files...
del /Q /F /S "C:\Windows\Temp\*"
echo Emptying Recycle Bin...
rd /s /q C:\$Recycle.Bin
echo Clearing Windows Cache...
del /q /f /s %temp%\*
echo Cleanup Finished!
pause
Save this script with a `.bat` extension, and you can execute it whenever you need to perform a quick clean-up.

Additional Tips for Disk Maintenance
Scheduling Regular Clean-Ups
It's beneficial to set routine maintenance tasks. You can automate your cleanup tasks using Task Scheduler. Set your batch file to run at regular intervals to keep your hard drive clean without manual intervention.
Importance of Backup Before Cleaning
Always emphasize the need to back up important data before conducting large clean-ups. Using tools like File History or Backup and Restore ensures your crucial files remain safe.

Conclusion
Maintaining a clean hard drive is crucial for optimal performance and storage management. By leveraging CMD commands, you can efficiently clean your hard drive in Windows 10, freeing up valuable space and ensuring your system runs smoothly. Regular maintenance, backed by an understanding of basic and advanced CMD functions, empowers you to take control of your computer's health.