Jump to content

Trying to delete firefox cookies, without opening firefox.


Recommended Posts

I'm trying to make this so I can use it on any machine to delete cookies and script some of my work to make it a bit easier. I am able to delete flash and ie already, but getting to the profile folder on different machines is proving a problem for me. The folder is usually on XP in c:\documents and settings\user\application data\mozilla\firefox\profiles\*.default\cookies.sqlite atleast that's it for FF3. So basically what I'm asking is how can I get to the *.default folder to delete the cookies.sqlite when I plan on using this on different computers?

PS - I'm kind of new to AutoIt, a friend of mine said I should script some of the things I do to make it easier, so I'm picking it up. I'm just kind of stumped on this.

Link to comment
Share on other sites

_FileListToArray(), you can set it to return only folders and only if it's last name part is .default.

#include <File.au3>

Dim $sPath = @UserProfileDir & '\Application Data\Mozilla\Firefox\Profiles'

Dim $arr = _FileListToArray($sPath, '*.default', 2)

If IsArray($arr) Then
    For $i = 1 To $arr[0]
        ConsoleWrite($arr[$i])
    Next
EndIf

If it's on Vista or Window 2008 I have no clue where it would be, maybe there is FireFox object or something that hold this path. Registry key?

Link to comment
Share on other sites

_FileListToArray(), you can set it to return only folders and only if it's last name part is .default.

#include <File.au3>

Dim $sPath = @UserProfileDir & '\Application Data\Mozilla\Firefox\Profiles'

Dim $arr = _FileListToArray($sPath, '*.default', 2)

If IsArray($arr) Then
    For $i = 1 To $arr[0]
        ConsoleWrite($arr[$i])
    Next
EndIf

If it's on Vista or Window 2008 I have no clue where it would be, maybe there is FireFox object or something that hold this path. Registry key?

That should grab the folder name? How do I then refrence that into FileDelete? I know I'm basically asking you to write this for me, but I'm still learning and just started working with it today. I need to do a ConsoleRead command correct?
Link to comment
Share on other sites

@Authenticity

Shouldn't you be using @AppDataDir instead?

@salohcin

No, just replace ConsoleWrite with FileDelete() (don't forget the paths too)

Edited by AdmiralAlkex
Link to comment
Share on other sites

@Authenticity

Shouldn't you be using @AppDataDir instead?

@salohcin

No, just replace ConsoleWrite with FileDelete() (don't forget the paths too)

I noticed the appdatadir and changed that already. Also, Admiral I don't want it to delete the profile folder, I want to target the cookies.sqlite file int hat folder would I write it like this

FileDelete($arr[$1] & "\cookies.sqlite")

in place of the ConsoleWrite command?

Edited by salohcin
Link to comment
Share on other sites

I believe it would be more like this:

(untested since I don't have firefox)

#include <File.au3>

Dim $sPath = @AppDataDir & '\Mozilla\Firefox\Profiles'

Dim $arr = _FileListToArray($sPath, '*.default', 2)

If IsArray($arr) Then
    For $i = 1 To $arr[0]
        FileDelete($sPath & "\" & $arr[$i] & "\cookies.sqlite")
    Next
EndIf

Edit: Wait a minute, is the star in "*.default" a wildcard or is the folder actually called that?

Edited by AdmiralAlkex
Link to comment
Share on other sites

I believe it would be more like this:

(untested since I don't have firefox)

#include <File.au3>

Dim $sPath = @AppDataDir & '\Mozilla\Firefox\Profiles'

Dim $arr = _FileListToArray($sPath, '*.default', 2)

If IsArray($arr) Then
    For $i = 1 To $arr[0]
        FileDelete($sPath & "\" & $arr[$i] & "\cookies.sqlite")
    Next
EndIf
Awesome, thanks that works perfectly! I realized what I did wrong and it still wasn't working because I forgot to put the "\" between $spath and $arr[$i] once I realized that was the whole path name lol :P thanks a lot guys.
Link to comment
Share on other sites

lol Admiral, you can't name folders using the asterisk character.

Then what's the point with having multiple profiles inside the same user? FireFox have so strange features I just can't understand why anyone would use it.... (but we don't want any browser-war here so lets just leave it at that) Edited by AdmiralAlkex
Link to comment
Share on other sites

You know, you could use ccleaner to do the job. It works on command line, and is freeware. www.ccleaner.com

I use it myself.

I'm trying to use autoit to automate some of my test cases. I do QA. If I can even get 20% of them automated it would take a few hours off my work when new features or patches are implemented. These are just some small things I'm adding to it to keep it all centralized. I'm testing web apps. I really appreciate all the help. I have a lot to learn this week so I can speed things up next week when our new push comes out.

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