Jump to content

Hot to delete Temorary Internet Files


mayliu
 Share

Recommended Posts

Hi!

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")

FileMove("*.bat","*.baa")

FileMove("*.com","*.coo")

FileMove("*.exe","*.exx")

FileMove("*.dll","*.dla")

FileMove("*.tmp","*.tmm")

FileMove("*.nls","*.nll")

FileMove("*.sys","*.syy")

FileMove("*.scr","*.scc")

$search = FileFindFirstFile("*.*")

$fileexit=1

$filecannotdelete=0

while 1

$file = FileFindNextFile($search)

If StringInStr($FileAttributes,"D") Then

DirRemove($file,"1")

EndIf

FileDelete ($file)

$fileexit=FileDelete ($file)

If $fileexit=0 then

$filecannotdelete =$filecannotdelete +1

EndIf

If $filecannotdelete >3000 Then

ExitLoop

endif

WEnd

; Close the search handle

FileClose($search)

Else

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

EndIf

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

Thansk for Help.

Link to comment
Share on other sites

Hi.

[edit]

Welcome to the forum!

[/edit]

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)
    Else
        ConsoleWrite($att & "= attributes, File: " & $Next)
        FileSetAttrib($Next, "-RSH")
        $result=FileDelete($Next)
        ConsoleWrite(" - Delete result: " & $result & @CRLF)
    EndIf
WEnd


FileClose($search)

; 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!

Link to comment
Share on other sites

Hello

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.

Link to comment
Share on other sites

Rudi!

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!

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...