If you’re looking to clean up your Windows 10 PC and get rid of those pesky junk files, using Command Prompt (CMD) is a quick and efficient way to do it. By following a few simple steps, you can easily delete unnecessary files that are taking up valuable space on your computer. This guide will walk you through the entire process, ensuring that your system runs smoother and faster.
How to Delete Junk Files in Windows 10 Using CMD
In this section, you’ll learn how to use Command Prompt to delete junk files in Windows 10. This method is particularly useful because it allows for precise control over what files are removed, ensuring that only unwanted files are deleted.
Step 1: Open Command Prompt as Administrator
First, you need to open Command Prompt with administrative privileges.
To do this, type "cmd" in the Windows search bar, right-click on Command Prompt, and select “Run as administrator.” This ensures you have the necessary permissions to delete system files.
Step 2: Use the Cleanmgr Command
Next, you’ll use the built-in Cleanmgr command to start the cleanup process.
Type "cleanmgr /sageset:1" and hit Enter. A window will appear allowing you to select the types of files you want to delete. This step sets up a configuration that you’ll run in the next step.
Step 3: Run the Cleanup Configuration
Now you need to execute the cleanup using the configuration you set up in Step 2.
Type "cleanmgr /sagerun:1" and press Enter. This command will run the Disk Cleanup utility using the settings you specified, removing the selected junk files.
Step 4: Delete Temporary Files
To specifically delete temporary files, use a dedicated command.
Type "del /q/f/s %TEMP%*" and hit Enter. This command will delete all temporary files in the TEMP folder without asking for confirmation.
Step 5: Clear the Prefetch Folder
Lastly, clean out the Prefetch folder to further optimize your system.
Type "del C:WindowsPrefetch*.* /Q" and press Enter. This will remove all files in the Prefetch folder, which helps the system start programs faster but can get cluttered over time.
Once you complete these steps, your computer should run a little smoother and have more free space. You might not notice a dramatic change immediately, but these steps help maintain your system over the long term.
Tips for Deleting Junk Files in Windows 10 Using CMD
- Always run Command Prompt as an administrator to have full access.
- Double-check the files you are deleting to avoid removing something important.
- Use Disk Cleanup regularly to keep your system optimized.
- Create a restore point before making significant changes, just in case something goes wrong.
- Be cautious when using wildcards (*) in CMD commands to avoid unintended deletions.
Frequently Asked Questions
Can I undo deleting files using CMD?
No, once files are deleted using CMD, they are not sent to the Recycle Bin and cannot be easily restored. Always double-check before proceeding.
Is it safe to delete the Prefetch folder?
Yes, it’s safe. The system will recreate necessary files the next time it boots up.
What types of files are considered junk?
Junk files include temporary files, system cache, log files, and files in the Recycle Bin.
How often should I delete junk files?
It’s a good idea to clean up junk files at least once a month to keep your system running smoothly.
Will deleting junk files speed up my computer?
Yes, removing unnecessary files can free up space and improve system performance, although the change might not be drastic.
Summary
- Open Command Prompt as Administrator.
- Use the Cleanmgr Command.
- Run the Cleanup Configuration.
- Delete Temporary Files.
- Clear the Prefetch Folder.
Conclusion
Deleting junk files in Windows 10 using CMD is a straightforward way to keep your computer clean and running efficiently. While modern systems are pretty good at managing storage, taking control and cleaning up manually can make a noticeable difference. Think of it like cleaning out your closet—you might not need to do it every day, but regular maintenance helps keep everything in order.
Try integrating these steps into your monthly routine. Not only will your computer thank you, but you’ll also enjoy a more responsive and faster system. If you found this guide helpful, consider checking out other ways to optimize your computer’s performance. Happy cleaning!

Kermit Matthews is a freelance writer based in Philadelphia, Pennsylvania with more than a decade of experience writing technology guides. He has a Bachelor’s and Master’s degree in Computer Science and has spent much of his professional career in IT management.
He specializes in writing content about iPhones, Android devices, Microsoft Office, and many other popular applications and devices.