defrag c:
You can run the defrag command using optional switches. Refer to the article: Defrag command in Windows to better understand how to use different syntax with the defrag command to perform analysis, add exceptions, change priority, etc.
You can use the Run command to perform a quick disk cleanup without opening the Command Prompt. It's useful if you want to free up a few gigabytes of storage in two steps. This requires you to start the Disk Cleanup tool and specify the drive you want to clean through the Run dialog box.
To run Disk Cleanup:
C:windowsSYSTEM32cleanmgr.exe /dDrive
C:windowsSYSTEM32cleanmgr.exe /dE
Disk Cleanup is a built-in Windows utility to help you free up space on your computer's hard drive. It can clean downloads, temporary Internet files, Recycle bin and even system files.
You can use Command Prompt to launch Disk Cleanup and perform automatic cleanup tasks directly. Here's how to use the tool and what command line switches are supported.
You can use the cleanmgr command to launch the Disk Cleanup tool using Command Prompt.
You can use the cleanmgr command followed by the drive letter to run the Disk Cleanup tool against that drive. This is useful for freeing up space on a specific drive. For example, use the following command to run the Disk Cleanup tool on drive C:
cleanmgr /D C
The Disk Cleanup tool will scan and display all the files you can delete. Make your selection and click OK .
To customize Disk Cleanup tool settings, the cleanmgr command supports multiple switches, including sageset and sagerun.
Here's how it works:
1. Enter the following command into Command Prompt and press Enter :
cleanmgr /sageset:1
2. In the command above, replace 1 with any number from 1 to 9999 . This guide will use 1 . When executed, it will open the Disk Cleanup tool and display all the junk items that you can delete.
3. Select or deselect all the items you want to delete. For example, select temporary setup files, Windows Update Cleanup, downloaded program files, Recycle bin (be careful with this file), etc.
4. After selecting the file types to clean, click OK to save the configuration.
5. Now, use the following command to run the Disk Cleanup tool with your custom configuration:
cleanmgr /sagerun:1
6. This will launch the Disk Cleanup tool and start cleaning the file types previously specified and assigned to the value 1. In this case, it will delete temporary setup files, Windows Update Cleanup, downloaded program files and Recycle bin files.
The lowdisk switch , as the name suggests, is useful if you are running out of storage space on your hard drive. When executed, it will automatically check all file types.
The lowdisk command is followed by the drive letter for the partition to free up space. A complete command will look something like this:
cleanmgr /lowdisk /d
When executed, Disk Cleanup will open with all junk file categories selected in drive D:.
To delete all junk files quickly without user prompts, use the following command instead:
cleanmgr /verylowdisk /d
Windows creates temporary files for use. They rarely take up a large amount of space on your hard drive and are essential for the system to function smoothly. When the task is complete, your system will automatically remove them from the temporary folders.
The Disk Cleanup tool will clean up temporary files older than 7 days. But if you have to clean your temporary folder regularly, you can do it manually or use Command Prompt.
To view temporary files, enter the following command in Command Prompt:
%SystemRoot%explorer.exe %temp%
You can delete these files manually ( Ctrl + A > Delete ) from File Explorer or use the following command to delete temporary files:
del %temp%*.* /s /q
Command Prompt will automatically skip any files that are currently in use but it will delete the rest.
Prefetch files are temporary files created when an application runs on your Windows system. These files contain information used to optimize program execution.
Like other temporary files, prefetch files usually don't take up much space on your hard drive. However, if you need to delete prefetch files regularly, you can use Command Prompt to clean up these files on your system.
To delete prefetched files using Command Prompt:
1. Open Command Prompt with admin rights.
2. In the Command Prompt window, type the following command to view prefetched files:
%SystemRoot%explorer.exe C:Windowsprefetch
3. The command will open the Prefetch folder in File Explorer and display prefetch files that you can delete.
4. To delete prefetched files, use the following command and press Enter :
del C:Windowsprefetch*.*/s/q
5. Command Prompt will display a list of all deleted prefetch files.
If you want to wipe the entire disk, you can use the diskpart utility. Diskpart is a Windows command line utility that supports more than 38 commands for various functions.
To wipe the drive, you can use diskpart's clean command. Once executed, it deletes all data and converts the drive to unallocated space.
Use caution when using the diskpart utility. Using incorrect objects can cause you to lose all your data, and you may not be able to recover any of it. Therefore, make a backup of your important system data before using the diskpart tool.
To erase a drive:
Select disk 0
Clean all