Automated cleanup of Temp files, Internet files, downloaded files, recycle bin.
Syntax CLEANMGR option Options /d driveletter: Select the drive that you want Disk Cleanup to clean. /sageset:n Display the Disk Cleanup Settings dialog box and create a registry key to store the settings you select. The n value is stored in the registry and allows you to specify different tasks for Disk Cleanup to run. n can be any integer from 0 to 65535. Specify the %systemroot% drive to see all the available options. /sagerun:n Run task 'n' All drives in the computer will be enumerated, and the selected profile will be run against each drive. Only one of the 3 options above can be run at a time /TUNEUP:n Run sageset + sagerun for the same n /LOWDISK Run with the default settings. /VERYLOWDISK Run with the default settings, no user prompts. /SETUP Undocumented /Help Undocumented /Usage Undocumented /? Display help
To enable Cleanmgr on Windows 2008, open Server Manager and choose 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.
Registry settings for CLEANMGR are held in:
Options that can be chosen for cleanup:
Temporary Internet Files
Temporary Setup Files
Downloaded Program Files
Old Chkdsk Files
Temporary Offline Files
Compress Old Files
Catalog Files for the Content Indexer
System files: Debug/chkdsk/Installer/Memory dump/Windows update/error reporting logs.
Items in bold can appear in more than one drive i.e not just in %SystemRoot%
Many files in Application Data hold system data that should not be deleted, however some applications do leave files which you can delete from a roaming profile, these can be selectively removed with a VBScript like this.
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.
To clear out the shortcuts:
echo y| del *.*
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.
”Mrs. Joe was a very clean housekeeper, but had an exquisite art of making her cleanliness more uncomfortable and unacceptable than dirt itself“ ~ Charles Dickens
DELPROF - Delete user profiles and/or User Profile cache
DEFRAG - Defragment hard drive (XP)
Q253597 - Automating Disk Cleanup in Windows
Equivalent bash command (Linux): watch - Execute/display a program periodically