Sign in to follow this  
Followers 0

Hot to delete Temorary Internet Files

5 posts in this topic


I met a question.

I wrote some statements and want to delete all files stored in Windows xp\Documents and settings\User\Local settings\Temporary Internet Files,but when i run this script,nothings happen.

All files in "Temporary Internet Fiels" are exists.

I guess if the file "index.dat" cannot be deleted ,so other files cannot deltete .

I wrote some statement for deleting "Temp" and it can work. Statement is as below:

Dim $FileAttributes = FileGetAttrib(@Tempdir)

DirRemove (@Tempdir,1)

FileChangeDir (@UserProfileDir & "\Local Settings")

FileChangeDir ( @TempDir )

If FileExists( @TempDir ) Then

FileSetAttrib("*.*", "-R-S-H")









$search = FileFindFirstFile("*.*")



while 1

$file = FileFindNextFile($search)

If StringInStr($FileAttributes,"D") Then



FileDelete ($file)

$fileexit=FileDelete ($file)

If $fileexit=0 then

$filecannotdelete =$filecannotdelete +1


If $filecannotdelete >3000 Then




; Close the search handle



DirCreate (@UserProfileDir & "\Local Settings\Temp")


But when I substitue \local setting\temp for \loca settings\temporary internet files ,no files are deleted.

Thansk for Help.

Share this post

Link to post
Share on other sites

#2 ·  Posted (edited)



Welcome to the forum!


The best one would be to trigger the action that's launched from IE's extra, options, .... (I don't know howto)

; be indipendent of the local Windows' language...
$IECache = RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "Cache")
ConsoleWrite($IECache & @CRLF)
$IECache = StringReplace($IECache, "%userprofile%", @UserProfileDir)
ConsoleWrite($IECache & @CRLF)

$search = FileFindFirstFile($IECache & "\*")
If @error Then Exit ;nothing found at all
While 1
    $Next = FileFindNextFile($search)
    If @error Then ExitLoop
    $Next = $IECache & "\" & $Next
    $att = FileGetAttrib($Next)
    If StringInStr($att, "d") Then
        ConsoleWrite($att & "= attributes, Dir:  " & $Next)
        FileSetAttrib($Next, "-RSH", 1)
        $result=DirRemove($Next, 1)
        ConsoleWrite(" - Delete result: " & $result & @CRLF)
        ConsoleWrite($att & "= attributes, File: " & $Next)
        FileSetAttrib($Next, "-RSH")
        ConsoleWrite(" - Delete result: " & $result & @CRLF)


; content.IE5 remains undeleted.

; this next line deletes for me everything but the folder Content.IE5 itself and the "index.dat" in it:
run(@ComSpec & ' /c rd /s /q "' & $IECache & '\Content.IE5"',$IECache,@SW_SHOW)

run("Explorer /e," & $IECache)

Regards, Rudi.

Edited by rudi

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post

Link to post
Share on other sites


If you want to Delete IE's Temporary Internet Files,

you should not go and delete the files directly.

You should ask IE to do it, and it will do it for you.

You can ask that from IE in 2 ways:

1) via automating the interface(Goto Menu:Tools\Options, and under "Browsing History" Click the "Delete..." Button, etc..)

2) via Command-Line Parameters.

If you search google for IE7 "command line" delete "Temporary Internet Files", you will find the needed parameters for doing it.

The second option is actually the shortest way to do it.

Share this post

Link to post
Share on other sites

#4 ·  Posted (edited)


Thanks for your Help!

My Problem is OK.

Edited by mayliu

Share this post

Link to post
Share on other sites


Thanks for your Help!

You are welcome. But the answer of Zohar is the approach that I mentioned to be the better one without knowing how to do it. So you might prefer to use that one instead :)

Google found this one

. As such pages tend to disappear, I cite it here:

Delete Temporary Internet Files
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8 

Delete Cookies
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2 

Delete History
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 1 

Delete Form Data
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 16 

Delete Stored Passwords
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 32 

Delete All
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255 

Delete All with the "Also delete files and settings stored by add-ons" options selected
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 4351 

Now it seems that the interesting bit is that you can combine the numbers to get 2 or more functions at the same time. For example, type:
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 9

Regards, Rudi.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
Followers 0