Running Disk Cleanup Tool in Command Line in Windows 10

0

Disk Cleanup is a built-in Windows tool that helps end user clean up disk spaces. Normally, you can launch the tool from disk drive’s properties, like below.

But do you also know that it can be launched as a command line with a bunch of switches that can be useful in various situations?

Let’s see how many switches are available in the tool by running the following command from a Run dialog box.

cleanmgr.exe /?

Addition to that, you can use the following switch to run the tool on a specified disk drive.

/D DriveLetter

For example, running

cleanmgr.exe /d c

launches the Disk Cleanup Tool for drive c:.

The switch /LOWDISK is used when a disk drive is running low in disk space. When launched, Disk Cleanup tool opens with all checkboxes checked by default.

cleanmgr.exe /lowdisk /d c

The command will launch Disk Cleanup tool against the drive c with all checkbox checked by default.

Click OK to start the cleaning process.

If you want the process to start automatically, use the switch /VERYLOWDISK instead. It does exactly the same as the /LOWDISK does but starts the cleaning process automatically.

cleanmgr.exe /verylowdisk /d c

Also, running the above command line from an elevated command prompt window will switch to the System Files mode, the mode when you click Clean up system files button in the screenshot above.

If you would like to have a customized checkbox settings, you can use the switch /SAGESET to set up the settings and /SAGERUN to use it. For example,

cleanmgr.exe /sageset:10

will save the checkbox settings in the registry and then can be called up by using

cleanmgr.exe /sagerun:10

Lastly, the /SETUP switch analyzes the system files left from a previous Windows version. If you are one of the Windows insiders, you will find this very helpful.

cleanmgr.exe /setup

It will analyze the following locations:

C:\$Windows.~BT\*
C:\$Windows.~LS\*
C:\$Windows.~WS\*
C:\ESD\Download\*
C:\ESD\Windows\*
C:\$WINDOWS.~Q\*
C:\$INPLACE.~TR\*
C:\Windows.old\*
C:\Windows\Panther

and saves two log files for you to inspect:

C:\Windows\System32\LogFiles\setupcln\setupact.log
C:\Windows\System32\LogFiles\setupcln\setuperr.log

To automatically clean up these left behind system files, use /AUTOCLEAN instead.

SHARE

LEAVE A REPLY

Please enter your comment!
Please enter your name here