Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

List/Remove Temporary Internet Files


  • Please log in to reply
8 replies to this topic
Laszlo
  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005
Temporary Internet Files cannot be listed or deleted with the AHK file commands, but the console DIR and DEL commands, with the right options, work. This little script puts up a GUI with a scrollable list of all the temporary internet files. Clicking on one, pops up a confirmation dialog, asking if you want to delete it. If NO, nothing happens, if YES, the selected file is deleted and removed from the list. You can continue removing files. Esc or closing the GUI with the upper right corner [x] exits the script.

It is only the basic functionality. You could extend it with error checking, a refresh- and an exit button, view of the selected file, sort by date or time, multiple selections, special handling of .ini or .dat files, etc.

Because the script deletes files, be careful, not to select important ones, and double check the code before use! I only tested on WinXP.
TIF = %USERPROFILE%\Local Settings\Temporary Internet Files
RunWait %comspec% /c dir "%TIF%" /A:-D /B /S > c:\dir.tmp,,HIDE
FileRead files, c:\dir.tmp
FileDelete c:\dir.tmp
StringReplace files, files, %TIF%\,,ALL
StringReplace files, files, `r`n, |, ALL

GUI:
   Gui Add, ListBox, w600 h300 HScroll vFILE gFILE, %files%
   Gui Show
Return

FILE:
   Gui Submit, NoHide
   MsgBox 4,,Delete Temporary file?`n%TIF%\%FILE%
   IfMsgBox No
      Return
   Run %comspec% /c del /F "%TIF%\%FILE%",,HIDE
   StringReplace files, files, %file%|
   Gui Destroy
GoTo GUI

GuiEscape:
GuiClose:
   ExitApp
Edit 20060319: Delete temp file, remove `r (Thanks Titan)
Edit 20060320: Save a line with the standard delimiter |, Hide the console at cmd DEL

polyethene
  • Members
  • 5519 posts
  • Last active: May 17 2015 06:39 AM
  • Joined: 26 Oct 2012
Nice solution. May I suggest deleting dir.tmp after it's read. Also you should add StringReplace files, files, `r, ,1 (after the first StringReplace) becuse without it there is a weird character at the end of every list item.

autohotkey.com/net Site Manager

 

Contact me by email (polyethene at autohotkey.net) or message tidbit


Laszlo
  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005

May I suggest deleting dir.tmp after it's read. Also you should add StringReplace files, files, `r, ,1 (after the first StringReplace)...

Done. Thanks!

polyethene
  • Members
  • 5519 posts
  • Last active: May 17 2015 06:39 AM
  • Joined: 26 Oct 2012
I think this is really useful because you can monitor internet usage. Below is the same thing in an easy to use function form. If the delimiter parametere is used, that will be used to seperate the list instead of `n.
tempfiles(delimiter=0) {

	TIF = %UserProfile%\Local Settings\Temporary Internet Files

	RunWait, %comspec% /c dir "%TIF%" /A:-D /B /S > %temp%\dir.tmp, , Hide

	FileRead, files, %temp%\dir.tmp

	FileDelete, %temp%\dir.tmp

	StringReplace, files, files, %TIF%\, , 1

	StringReplace, files, files, `r, , 1

	If delimiter

		StringReplace, files, files, `n, %delimiter%, 1

	Return, files

}

autohotkey.com/net Site Manager

 

Contact me by email (polyethene at autohotkey.net) or message tidbit


Laszlo
  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005
couple of minor changes posted

Kanabec
  • Guests
  • Last active:
  • Joined: --
Great script, thanks for sharing!

I believe this works with the logged in user?
I wonder how it could be done to clear temp files for all users on a machine that has multiple profiles?

heresy
  • Members
  • 291 posts
  • Last active: Sep 26 2008 10:47 PM
  • Joined: 11 Mar 2008
TIF = %USERPROFILE%\Local Settings\Temporary Internet Files

is there anyway to get right dir name?
cause if you change folder for Temporary Internet Files in other language windows.
the directory name automatically created in local language other than 'Temporary Internet Files'
and even in windows vista it has different location

On Windows Vista, the cache is usually located at %USERPROFILE%\AppData\Local\Microsoft\Windows\Temporary Internet Files and
%USERPROFILE%\AppData\Local\Microsoft\Windows\Temporary Internet Files\Low\Content.IE5 for Internet Explorer 7



heresy
  • Members
  • 291 posts
  • Last active: Sep 26 2008 10:47 PM
  • Joined: 11 Mar 2008

TIF = %USERPROFILE%\Local Settings\Temporary Internet Files

is there anyway to get right dir name?
cause if you change folder for Temporary Internet Files in other language windows.
the directory name automatically created in local language other than 'Temporary Internet Files'
and even in windows vista it has different location

On Windows Vista, the cache is usually located at %USERPROFILE%\AppData\Local\Microsoft\Windows\Temporary Internet Files and
%USERPROFILE%\AppData\Local\Microsoft\Windows\Temporary Internet Files\Low\Content.IE5 for Internet Explorer 7



Self Answering.
i think i found it

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Cache

it would be good to change like this
Rootkey = HKEY_CURRENT_USER
SubKey = Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
RegRead, TIF, %RootKey%, %SubKey%, Cache

but haven't tested it in vista

tonne
  • Members
  • 1654 posts
  • Last active: May 06 2014 06:22 PM
  • Joined: 06 Jun 2006
Confirmed in Vista.