Jump to content

Deleting Internet Explorer Cookies


Recommended Posts

Hi All,

I've been trying to write a small script to remove all Internet Explorer cookies, but I'm apparently having some trouble. I wasn't exactly sure which directory held all of the cookies because there are so many, but in my code below I'm positive that it's the second element in the array (at least for windows 7). I seem to be having trouble deleting the files in there though.. it just doesn't work. Here's my code thus far:

#include <Array.au3>
#include <File.au3>

Local $aDirectories[6]
$aDirectories[0] = @UserProfileDir&"\Cookies"
$aDirectories[1] = @UserProfileDir&"\AppData\Local\Microsoft\Windows\Temporary Internet Files"
$aDirectories[2] = @UserProfileDir&"\Local Settings\Temporary Internet Files"
$aDirectories[3] = @AppDataDir&"\Local\Microsoft\Windows\Temporary Internet Files"
$aDirectories[4] = @AppDataDir&"\Roaming\Microsoft\Windows\Cookies\Low"
$aDirectories[5] = @AppDataDir&"\Roaming\Microsoft\Windows\Cookies\Low\Temporary Internet Files"

For $Directory in $aDirectories
    If FileExists($Directory) Then
        $FileList=_FileListToArray($Directory, "*")
        For $i = 0 To UBound($FileList) - 1
            $File = $Directory & "\" & $FileList[$i]
            If FileExists($File) Then
                FileDelete($File)
            EndIf
        Next
    EndIf
Next

Help? :mellow:

Link to comment
Share on other sites

"it just doesn't work" is not offering much helpful info is it.

How about what about it dosent work, what error you receive etc...

It's not deleting the files in the directories. I'm not getting any error message.. just the files aren't getting deleted. :mellow:

Link to comment
Share on other sites

What about this >>

#include <Array.au3>
#include <File.au3>

Global $aDirectories[6], $aFileList
$aDirectories[0] = @UserProfileDir & "\Cookies"
$aDirectories[1] = @UserProfileDir & "\AppData\Local\Microsoft\Windows\Temporary Internet Files"
$aDirectories[2] = @UserProfileDir & "\Local Settings\Temporary Internet Files"
$aDirectories[3] = @AppDataDir & "\Local\Microsoft\Windows\Temporary Internet Files"
$aDirectories[4] = @AppDataDir & "\Roaming\Microsoft\Windows\Cookies\Low"
$aDirectories[5] = @AppDataDir & "\Roaming\Microsoft\Windows\Cookies\Low\Temporary Internet Files"

For $A = 0 To 5
    If FileExists($aDirectories[$A]) Then
        $aFileList = _FileListToArray($aDirectories[$A])
        If @error Then
            ContinueLoop
        EndIf
        For $B = 1 To $aFileList[0]
            ConsoleWrite("FileDelete(" & $aDirectories[$A] & "\" & $aFileList[$B] & ")" & @LF)
        Next
    EndIf
Next

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

What about this >>

#include <Array.au3>
#include <File.au3>

Global $aDirectories[6], $aFileList
$aDirectories[0] = @UserProfileDir & "\Cookies"
$aDirectories[1] = @UserProfileDir & "\AppData\Local\Microsoft\Windows\Temporary Internet Files"
$aDirectories[2] = @UserProfileDir & "\Local Settings\Temporary Internet Files"
$aDirectories[3] = @AppDataDir & "\Local\Microsoft\Windows\Temporary Internet Files"
$aDirectories[4] = @AppDataDir & "\Roaming\Microsoft\Windows\Cookies\Low"
$aDirectories[5] = @AppDataDir & "\Roaming\Microsoft\Windows\Cookies\Low\Temporary Internet Files"

For $A = 0 To 5
    If FileExists($aDirectories[$A]) Then
        $aFileList = _FileListToArray($aDirectories[$A])
        If @error Then
            ContinueLoop
        EndIf
        For $B = 1 To $aFileList[0]
            ConsoleWrite("FileDelete(" & $aDirectories[$A] & "\" & $aFileList[$B] & ")" & @LF)
        Next
    EndIf
Next

I'm still having the same problem as I was before.. it is only listing the directories inside of those folders and it's not actually deleting any content inside of them.
Link to comment
Share on other sites

Whoops! Use this to return files only and look at Melba23's signature for RecFileListToArray (this can search in subfolders too) it might also be a problem with access rights as well.

_FileListToArray($aDirectories[$A], "*", 1)

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Whoops! Use this to return files only and look at Melba23's signature for RecFileListToArray (this can search in subfolders too) it might also be a problem with access rights as well.

_FileListToArray($aDirectories[$A], "*", 1)

Using that the only output I get is:

FileDelete(C:\Users\Chris\AppData\Local\Microsoft\Windows\Temporary Internet Files\desktop.ini)

When I copy and paste that directly into my explorer (removing the desktop.ini) I'm presented with a lot more content in that directory than just the desktop.ini.
Link to comment
Share on other sites

You haven't -RASHOT'd the files. See FileSetAttrib in the Man pages. I had this problem too but I fixed it in my script (linky).

Edited by rcmaehl

My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

My Projects

WhyNotWin11
Cisco FinesseGithubIRC UDFWindowEx UDF

 

Link to comment
Share on other sites

I'm getting 500 errors when trying to go there

O_o You sure. Can you post the script here and let me try it?

My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

My Projects

WhyNotWin11
Cisco FinesseGithubIRC UDFWindowEx UDF

 

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...