Sign in to follow this  
Followers 0
salohcin

Trying to delete firefox cookies, without opening firefox.

13 posts in this topic

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.

Share this post


Link to post
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?

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

@Authenticity

Shouldn't you be using @AppDataDir instead?

@salohcin

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

Edited by AdmiralAlkex

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

@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

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

...

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

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

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

In this case, you can use AutoIt and ccleaner together to do what you describe. Ccleaner will do the cleaning, while AutoIt will do the automating.

Well I already have it done in AutoIt to do the cleaning =)

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