AutoHotkey Community

It is currently May 27th, 2012, 11:17 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: March 19th, 2006, 6:19 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
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.
Code:
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


Last edited by Laszlo on March 20th, 2006, 11:29 pm, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 19th, 2006, 6:46 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5347
Location: UK
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.

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 19th, 2006, 9:19 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
Titan wrote:
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!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 19th, 2006, 9:33 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5347
Location: UK
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.
Code:
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
}

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 20th, 2006, 11:30 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
couple of minor changes posted


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Multiple users?
PostPosted: April 5th, 2008, 2:32 am 
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?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: April 7th, 2008, 9:30 pm 
Offline

Joined: March 11th, 2008, 11:36 pm
Posts: 291
Code:
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

Quote:
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 7th, 2008, 9:56 pm 
Offline

Joined: March 11th, 2008, 11:36 pm
Posts: 291
heresy wrote:
Code:
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

Quote:
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

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


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


but haven't tested it in vista


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 7th, 2008, 10:18 pm 
Offline

Joined: June 6th, 2006, 3:19 pm
Posts: 1654
Location: Denmark
Confirmed in Vista.

_________________
RegEx Powered Dynamic Hotstrings
COM
AutoHotkey 2


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: nomissenrojb, Rajat and 55 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group