CLEANMGR.exe – Windows CMD Command

Automated cleanup of Temporary files, Internet files, downloaded files, recycle bin.

If CLEANMGR is run without /sageset or /sagerun, it will start by calculating how much disk space could be saved. This makes the process much slower to run.

Some cleanup options require elevation, when run without elevation the GUI will include an option [Clean up System Files] which will relaunch CLEANMGR in Elevated mode.

Application Data

Many files in Application Data hold system data that should not be deleted, however, some applications do leave files that you can delete from a roaming profile, these can be selectively removed with a VBScript like this.

Recent files

The ‘User Profile/Recent’ folder (for Start, Documents) can contain many more shortcuts than are set to display in the GUI. A very large number of these can affect logon/logoff times.

Close Locked files by restarting Windows Explorer

Close all applications
Open a command prompt
taskkill /im explorer
This should kill explorer and bring up a logout/shutdown dialogue box.
Simultaneously press CTRL+SHIFT+ALT.
While you keep these keys pressed, click [Cancel] in the Shut Down Windows dialog box.
In the command prompt window, you should now be able to delete the locked files.
At the command prompt, type explorer, and press ENTER to restart Windows Explorer.

To enable Cleanmgr on Windows 2008, open Server Manager and choose to Add feature, then select “Desktop Experience”
After running cleanmgr on a server you will probably want to disable “Desktop Experience” again (or use this script.)
When necessary cleanmgr can take ownership of the files before deleting them.

You may also like...

1 Response

  1. graliontorile says:

    Hello. fantastic job. I did not anticipate this. This is a splendid story. Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *