≡ Menu

How to delete temporary Internet files

Temporary internet files are stored separately for each user account on Windows. These files can be deleted by running the following command from Windows command line.

Windows 7

In Windows 7, temporary internet files are stored in the folder AppData\Local\Temporary Internet Files. However this folder is not accessible by default. Checking the properties of the folder in explorer does not provide you any information related to file access permissions.

To delete these files, first we need to take ownership of the folder and it’s files. This can be accomplished by the below command.

takeown  /R /F  "%userprofile%\AppData\Local\Temporary Internet Files"

Refer Take ownership of file for detailed information on this command.

Once done, you can open the folder in explorer and delete the files. You are done!
To delete the files from command line, we need to run couple of commands.

  1. Delete the files in the folder.
    del "%userprofile%\AppData\Local\Temporary Internet Files\*"
  2. Delete the subfolders in ‘Temporary Internet Files’
    forfiles /P "%userprofile%\AppData\Local\Temporary Internet Files\*" /C "cmd /c if @isdir==TRUE rmdir /S /Q @file"

Instead of removing the whole directory, we use the above two commands to delete only the files and subfolders and keep the root folder untouched.

Application temporary files

On Windows 7 there’s another folder AppData\Local\Temp which keeps temporary files created by various applications run on the system. This cache can be deleted with the below commands.

del %userprofile%\AppData\Local\Temp\*
forfiles /P %userprofile%\AppData\Local\Temp\ /C "cmd /c if @isdir==TRUE rmdir /S /Q @file"

We can also verify that the environment variables TEMP or TMP points to this folder.

c:\>set t
TEMP=C:\Users\loginId\AppData\Local\Temp
TMP=C:\Users\loginId\AppData\Local\Temp

So deletion of temp files can also be done using this environment variable

del %TEMP%\*
forfiles /P %TEMP%\* /C "cmd /c if @isdir==TRUE rmdir /S /Q @file"

XP

rmdir /s /q "%userprofile%\Local Settings\Temporary Internet Files"

There is another temp folder where temporary files are kept. Suppose you view a pdf file online in the browser, then the file is actually stored in this temp folder. This is located in C:\Documents and Settings\username\Local Settings\Temp. The environment variable temp stores the path of this directory.

This temp folder can be cleaned up using the below command.

rmdir /s /q %temp%
2 comments… add one
  • commenter

    Thanks Alot!!!

  • JM

    Good, but no mention of handy/neccessary flags such as…

    del /s /f /q C:\Users\%username%\AppData\Local\Temporary Internet Files\*.*

Leave a Comment