Skip to content

Instantly share code, notes, and snippets.

@progcode
Last active January 16, 2017 15:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save progcode/0eda36d9bb9f4e65c50dbd3bbf2043de to your computer and use it in GitHub Desktop.
Save progcode/0eda36d9bb9f4e65c50dbd3bbf2043de to your computer and use it in GitHub Desktop.
WIN - delete temporary files

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

Delete the files in the folder.

del "%userprofile%\AppData\Local\Temporary Internet Files\*"

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"

Application temporary files

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
c:\> set TEMP=C:\Users\loginId\AppData\Local\Temp
c:\> set 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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment