Alter the "LastAccess" value for cleaning the Temporary files using Disk Cleanup utility

Published: April 23, 2005
Send your feedback


When you use the Disk Cleanup utility (cleanmgr.exe) to delete the files in %TEMP% folder, some of the files may not be deleted by the utility.


For temporary files cleanup, the Disk Cleanup utility does not delete files which have been accessed in the last 7 days.


You can configure Disk Cleanup utility such that it deletes all the files in the %TEMP% folder, irrespective of the last accessed date. To do so, alter the LastAccess value in this registry key:

HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Explorer \ VolumeCaches \ Temporary Files

MSDN article Creating a Disk Cleanup Handler explains the LastAccess registry value as follows:

The number of days that must have elapsed since a file was last accessed or a directory was created for that file or directory to be considered for cleanup.

Modifying the LastAccess value

Note that the default LastAccess value is 7 for Temporary files cleanup. You can change it to 4 or 5 (days). Setting it to 0 removes all the files in the folder.

Related article

Automate Disk Cleanup in Windows XP