Saturday, May 16, 2020

Delete a specific cookie using autohotkey

To delete cookies, we edit the .sqlite database file in Firefox's APPDATA containing Mozilla Firefox's cookies.

Run DB Browser from the Command Prompt (cmd.exe) with command line options to run a SQL script (-s ) on the cookie database file and quit after execution (-q)

AutoHotkey script code:
   run, cmd.exe
Send "%path_dbbrowser%" -s "%path_sqlscript%" -q "%path_cookie%"{ENTER}
In context:
    ; // program paths
    path_cookie := "C:\Users\__USERNAME__\AppData\Roaming\
    Mozilla\Firefox\Profiles\__PROFILENAME__\cookies.sqlite"     path_dbbrowser := "D:\Program Files\DB Browser for SQLite\
    DB Browser for SQLite.exe"     path_sqlscript := "E:\Code\autohotkey scripts\cox\deletecookies.sql"
    
    cmd_timeout_sec := 10 ; time to wait for command prompt to respond

    run, cmd.exe
WinActivate ahk_exe cmd.exe
WinWaitActive ahk_exe cmd.exe, , %cmd_timeout_sec%
Send "%path_dbbrowser%" -s "%path_sqlscript%" -q "%path_cookie%"{ENTER}
    Send Exit{ENTER}
Remember to declare variables as global inside the functions, if they were assigned in the main execution.

SQL script contents:

DELETE FROM moz_cookies WHERE host like "%cox%"; 

Relevant Applications:

DB Browser for SQLite
Autohotkey
Mozilla Firefox

No comments:

Post a Comment

You can add Images, Colored Text and more to your comment.
See instructions at http://macrolayer.blogspot.com..