This is going to be a small privacy tutorial on how to clear cache, cookies and history in all five major browsers - Internet Explorer, Chrome, Firefox, Opera and Safari. The techniques here work only on Windows operating system but it's not hard to transfer the techniques to other systems. The tutorial comes with Windows batch scripts for each browser. It also documents how to erase the nasty flash cookies that are browser independent.

I wrote these batch scripts for the Browserling startup that I am doing together with James Halliday. The problem was that the browsers had to be reset between consequent uses. The easiest way to solve it was to run a batch cleanup script after each browser.

Google Chrome

Chrome stores history, cookies, cache and bookmarks in various databases and directories in the per-user application data directory at C:\Users\<username>\AppData\Local\Google\Chrome\User Data. The easiest way to get rid of all this data is just to erase everything there. Chrome creates this directory anew if it finds it missing.

@echo off

set ChromeDir=C:\Users\%USERNAME%\AppData\Local\Google\Chrome\User Data

del /q /s /f "%ChromeDir%"
rd /s /q "%ChromeDir%"

This simple batch script first deletes all files in %ChromeDir% directory via del command and then deletes the directory itself via rd command. The /q flag makes the del command quiet, the /s makes it delete files from all subdirectories, and /f forces it to delete read-only files, too. The /s flag to rd makes it delete all subdirectories and /q makes rd quiet.

Mozilla Firefox

Firefox stores cookies, cache and history in two places. The first is per-user appdata directory C:\Users\<username>\AppData\Local\Mozilla\Firefox\Profiles and the second place is roaming profile data directory C:\Users\<username>\AppData\Roaming\Mozilla\Firefox\Profiles. To get rid of all the private data, delete the local data directory and delete all sqlite databases from the roaming data directory.

@echo off

set DataDir=C:\Users\%USERNAME%\AppData\Local\Mozilla\Firefox\Profiles

del /q /s /f "%DataDir%"
rd /s /q "%DataDir%"

for /d %%x in (C:\Users\%USERNAME%\AppData\Roaming\Mozilla\Firefox\Profiles\*) do del /q /s /f %%x\*sqlite

The for command loops over all profile directories and deletes all the sqlite databases. You can also delete the whole roaming data directory but I didn't because Firefox stores extensions there, and there are several I use for Browserling.


Opera also stores cookies, cache and history in two different locations - the user's application data directory C:\Users\<username>\AppData\Local\Opera\Opera and the user's roaming data directory C:\Users\<username>\AppData\Roaming\Opera\Opera. Just get rid of both directories and you're safe.

@echo off

set DataDir=C:\Users\%USERNAME%\AppData\Local\Opera\Opera
set DataDir2=C:\Users\%USERNAME%\AppData\Roaming\Opera\Opera

del /q /s /f "%DataDir%"
rd /s /q "%DataDir%"

del /q /s /f "%DataDir2%"
rd /s /q "%DataDir2%"

Apple Safari

Safari also stores cookies, cache and history in two locations - the user's application data directory C:\Users\<username>\AppData\Local\Apple Computer\Safari and user's roaming data directory C:\Users\<username>\AppData\Roaming\Apple Computer\Safari

@echo off

set DataDir=C:\Users\%USERNAME%\AppData\Local\Applec~1\Safari
set DataDir2=C:\Users\%USERNAME%\AppData\Roaming\Applec~1\Safari

del /q /s /f "%DataDir%\History"
rd /s /q "%DataDir%\History"

del /q /s /f "%DataDir%\Cache.db"
del /q /s /f "%DataDir%\WebpageIcons.db"

del /q /s /f "%DataDir2%"
rd /s /q "%DataDir2%"

Microsoft Internet Explorer

Internet Explorer is much more tricker. It stores history, cookies and cache all over the place, including registry. Here is the batch script that deletes all that data from all the places:

@echo off

set DataDir=C:\Users\%USERNAME%\AppData\Local\Microsoft\Intern~1

del /q /s /f "%DataDir%"
rd /s /q "%DataDir%"

set History=C:\Users\%USERNAME%\AppData\Local\Microsoft\Windows\History

del /q /s /f "%History%"
rd /s /q "%History%"

set IETemp=C:\Users\%USERNAME%\AppData\Local\Microsoft\Windows\Tempor~1

del /q /s /f "%IETemp%"
rd /s /q "%IETemp%"

set Cookies=C:\Users\%USERNAME%\AppData\Roaming\Microsoft\Windows\Cookies

del /q /s /f "%Cookies%"
rd /s /q "%Cookies%"

C:\bin\regdelete.exe HKEY_CURRENT_USER "Software\Microsoft\Internet Explorer\TypedURLs"

Notice that the last command is regdelete.exe. It's a small win32 utility that I wrote in c++ that erases the IE history, because it stores it in registry.

Here is the regdelete.c program:

#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <string>
// compile as: mingw32-g++ regdelete.c -o regdelete.exe -mwindows

#define eq(s1,s2) (strcmp((s1),(s2))==0)

int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR cmdLine, int nCmdShow) 
    if (!cmdLine || !strlen(cmdLine)) {
        printf("Usage: regdel.exe <HKEY> <path to regkey> - be careful not to delete whole registry\n");
        return 1;

    int argc;
    LPWSTR *argv = CommandLineToArgvW(GetCommandLineW(), &argc);

    if (argc < 3) {
        printf("Usage: regdel.exe <HKEY> <path to regkey> - be careful not to delete whole registry\n");
        return 1;

    char **argv8 = (char **)malloc(sizeof(char *) * argc);
    for (int i = 0; i<argc; i++) {
        int len = wcslen(argv[i]);
        argv8[i] = (char *)malloc(sizeof(char)*(len+1));
        wcstombs(argv8[i], argv[i], len+1);

    HKEY hkey;
    if (eq(argv8[1], "HKEY_CLASSES_ROOT")) {
        hkey == HKEY_CLASSES_ROOT;
    else if (eq(argv8[1], "HKEY_CURRENT_CONFIG")) {
        hkey = HKEY_CURRENT_CONFIG;
    else if (eq(argv8[1], "HKEY_CURRENT_USER")) {
        hkey = HKEY_CURRENT_USER;
    else if (eq(argv8[1], "HKEY_LOCAL_MACHINE")) {
        hkey = HKEY_LOCAL_MACHINE;
    else if (eq(argv8[1], "HKEY_USERS")) {
        hkey = HKEY_USERS;
    else {
        printf("Unknown hkey\n");
        return 1;

    HKEY key;
    int status = RegOpenKeyEx(hkey, argv8[2], 0, KEY_ALL_ACCESS, &key);
    if (status != ERROR_SUCCESS) {
        printf("failed opening %s\n", argv8[2]);
        return 1;

    std::vector<std::string> vals;

    for (unsigned int i = 0; ; i++) {
        DWORD size = 1024;
        char val[size+1];
        DWORD type;
        status = RegEnumValue(key, i, val, &size, NULL, &type, NULL, NULL);
        if (status == ERROR_NO_MORE_ITEMS) break;
        if (status == ERROR_SUCCESS) {
        printf("failed enumerating %s\n", argv8[2]);
        return 1;

    typedef std::vector<std::string>::iterator vsi;
    for (vsi i = vals.begin(); i != vals.end(); i++) {
        status = RegDeleteValue(key, i->c_str());
        if (status != ERROR_SUCCESS) {
            printf("failed deleting %s\n", i->c_str());
            return 1;

    return 0;

Compile this source code via mingw or visual studio and you'll have the regdelete.exe program.

Flash Cookies

Flash cookies reside in C:\Users\<username>\AppData\Roaming\Macromedia\Flash Player\*. The easiest way is to get rid everything in there:

@echo off

set FlashCookies=C:\Users\%USERNAME%\AppData\Roaming\Macromedia\Flashp~1

del /q /s /f "%FlashCookies%"
rd /s /q "%FlashCookies%"

That's it. Have fun clearing that cache!


December 02, 2010, 02:46

Errm, so... you delete everything from the cache, and whole directories? Not just your stuff?
Is that what this code is saying?

Let me take a second look.


So, I use your app, and you, ahem, wipe every cache item to reset it? Cache is not your data, it's mine. Who the hell are you to decide to wipe it all so YOUR app works?


You have the skills to pick your stuff out of the cache, I'm sure.. I've followed your blog for a while. Your approach seems a bit heavy handed.

We sure are learning a lot about you my man. This startup has been a great idea.

December 02, 2010, 04:05

Kevin, you completely misunderstood what this code is for. It's for the public (free) browserling instances. It does exactly what it's supposed to - it clears the cache, cookies, and history after you, so that the next user did not know who you were. You don't really want YOUR cache be seen by the next user!

For the private, paid accounts, of course, we will not be wiping cache, cookies or history. You'll have your own private account and you will be the only one who accesses it.

December 02, 2010, 15:59

My bad, this is a formal apology. I even read the code 2x but inexplicably did not check the context. Apologies, and seriously hoping the startup goes well. High hopes and all that, and of course you are right about the clean wiping of a remote instance.

It's just that many web apps ask you to wipe your cache for many reasons... but this does not excuse my lack of due diligence whatsoever.

December 03, 2010, 22:04

Apology accepted. :)

Mike Permalink
February 18, 2014, 20:09

DUDE, thanks for the coding

JayF_ITAnalyst Permalink
September 19, 2014, 06:16

Amateur-level scripting. Instead of typing out "C:\users\%username%\" Just use "%userprofile%\". Also, this can be accomplished much easier:

RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess

Specifically for clearing your history, temp cache, and cookies.

JayF_ITAnalyst Permalink
September 19, 2014, 06:44

This is a fun one! uses your boxes you have checked in internet explorer for deleting you crap. its .vbs format. Only tested on Win7.

dim wshshell
set wshshell = createobject("")
with wshshell
.run ("cmd")
wscript.sleep 100
.sendkeys "inetcpl.cpl ~"
wscript.sleep 100
.appactivate "C:\Windows"
wscript.sleep 100
.sendkeys "exit ~"
wscript.sleep 100
.sendkeys "d"
wscript.sleep 100
.sendkeys "d"
wscript.sleep 100
.appactivate "Internet Properties"
wscript.sleep 100
.sendkeys "%{F4}"
end with

Raf Permalink
March 18, 2015, 13:01

Nice Job!, how do i run this, and which scripting language did you use? I'm new here

Bill Permalink
May 25, 2016, 18:21

it also clears the bookmark folders in chrome. -that was not wanted.

juan Permalink
June 23, 2016, 10:04

can you please explain me if i can run the chrome script via group policy thanks

kevin earley Permalink
January 23, 2013, 19:15

Dude. You should not be implementing and executing code without understanding it. It's very clear what the code is doing. If you are not a coder, then again--you have no business messing around with it.

-The "Real" Kevin

gregf Permalink
December 02, 2010, 03:26

This is a bad idea. These scripts at least for firefox are deleting way more than just cookies. This includes all the user preferences, history, etc. On top of that there are better ways to do this build into the browser. At the very least you should be using sqlite to just drop the rows in cookies.sqlite.

December 02, 2010, 04:09

Gregf, please see my comment to Kevin above. I really do want to nuke everything for the public browserling use.

December 02, 2010, 04:05

Any discussion about browser cookies should also include flash cookies, which can only be done by visiting Adobe's site -

December 02, 2010, 04:25

Ah yes, I forgot to delete those. I just updated the article with information on how to get rid of the nasty flash cookies!

December 02, 2010, 12:31

pesky flash cookies! lotsa other ways to track critters though

December 02, 2010, 13:39

I cringe when I see your code... My eyes hurt!

Stop the C:\Users\%USERNAME%\AppData\Local nonsense, you cannot assume anyone has the same directory structure. Localized (non-English) Windows versions, different Windows versions (care to see your code blow up on XP?), all of these make your code unportable.

If you change every C:\Users\%USERNAME%\AppData\Local instance to %LOCALAPPDATA% then your code will be portable and my eyes will stop bleeding! For instances of C:\Users\%USERNAME%\AppData\Roaming you can use %APPDATA% instead. Typing in SET at the command prompt is your friend...

About the actual content, THANKS! It's always good to know how to erase abosolutely everything from your browsing history.

jang Permalink
December 02, 2010, 14:23

He can assume because it's his virtual machine, so he controls the OS and the folder location expected. That said I would probably use system states to reset everything, I presume it's more secure because even if the virtual machine is hacked, the vulnerability will stay, but any rogue software is wiped.

December 03, 2010, 22:05

Good tips, thanks!

December 14, 2010, 18:02

"...different Windows versions (care to see your code blow up on XP?), all of these make your code unportable. If you change every C:\Users\%USERNAME%\AppData\Local instance to %LOCALAPPDATA% then your code will be portable and my eyes will stop bleeding!"

No need to be hatin' on Peter, especially since your %LOCALAPPDATA% suggestion doesn't work in XP by default. That variable was first introduced in Vista, and needs to be added manually in XP for your tip to work:

JayF_ITAnalyst Permalink
September 19, 2014, 06:20

I was thinking the same thing. I almost cried while reading it.

asdf Permalink
December 02, 2010, 22:51

You have a typo, %ChomeDir% should be %ChromeDir%

December 03, 2010, 22:04

Hey thanks, fixing this typo now!

December 03, 2010, 01:30

Ugh, removing profile dir is the quickest way but i think it's too radical. Not quite applicable for single user case.

December 03, 2010, 22:04

I love quick and dirty approach. :)

Keith Miller Permalink
December 04, 2010, 19:37

Nice work, thank you for sharing it. I would recommend using Sysinternals sdelete for an added layer security.

hruum Permalink
December 28, 2010, 08:31

one more typo:
if (eq(argv8[1], "HKEY_CLASSES_ROOT")) {
should be
if (eq(argv8[1], "HKEY_CLASSES_ROOT")) {

reva Permalink
May 26, 2011, 09:19

i need to know how to do that on ff 4.0.1

steve Permalink
June 11, 2011, 09:57

This is what I always do to get rid of em

j doe Permalink
April 07, 2014, 18:33

howtohacklife101 blog is gone! Bummer. Can you repost the article, or the method/scripts?

Brandon Johnson Permalink
November 18, 2011, 14:56

Three major things:

First, as one former poster commented, you should use %APPDATA% and %LOCALAPPDATA% for portability.

Second, you should not clear IE cache that way. It's not portable to multiple languages/windows versions either. The correct way of clearing IE (7+) cache is to execute the API call of "ClearMyTracksByProcess" from InetCpl.cpl, like this:

REM Clear IE cache - 1 and 8 are Temp Files and History. Use 255 for all if you want to clear everything.
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 1

This will also remove the necessity of your C program.

Third, in the event you're running these all on a machine not knowing what browsers are on it, you'll get a ton of feedback and errors to STDOUT in the command line. Try adding:
1> nul 2>&1
to the end of each line to redirect STDOUT and STDERR to nul so it makes the execution silent, or at least pipe it to a file.

February 06, 2012, 05:11

I enjoyed your post and am experimenting with it now. As I am very new to programming, I was wondering if you knew a way to make this delete across all users of a computer.

Also I found a typo too. I believe
if (eq(argv8[1], "HKEY_CLASSES_ROOT")) {
Should be
if (eq(argv8[1], "HKEY_CLASSES_ROOT")) {

adam Permalink
August 06, 2012, 03:10

i use rmdir /s/q instead of del /q /s /f and rd /s /q :P

ranjith Permalink
August 22, 2012, 05:47

Hi , could you please provide a single script that will clear all the cookie information , for Browsers IE/FF/Safari/Chrome etc.

Thanks in advance


lucan Permalink
August 16, 2012, 23:11

any chance of a linux version of this info?

Christi D Devathala Permalink
September 06, 2012, 03:05

Hi, I am new to batch files and all. I use google chrome. I am very interested in just clearing ONLY browsing history, cookies, cache. I still want to be able to have bookmarks and saved passwords. Can someone please tell me how? Thanks

Igor Permalink
September 26, 2012, 10:02

what the f** with Microsoft Internet Explorer?
real command line is:
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 4351

Michael Permalink
December 14, 2012, 03:31

Any way to run this command RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 4351 without screen pop-up?
Please let me know... thanks, Michael

Leo Permalink
January 04, 2013, 15:48

So I'm looking to make a script to go through all users profiles on the local machine and clear out site specfic Cache NOT all just for a specific domain. having a hard time since you cant use the extended attributes on the Temporary Internet Files folder... any thoughts?

dan Permalink
February 13, 2013, 11:56

I would like to add another path to your FireFox browser history.




I have a new install of FireFox on my machine and I found tons of crap in this folder also.

venkatesh Permalink
August 21, 2013, 07:16

How to delete the browser cookies and history without deleting the bookmarks and saved passwords in the Firefox and Chrome browsers? Please help me.

Above mentioned very useful for me while doing cross browser testing. While executing the firefox and chrome codes,it deletes all things. I need to delete only cookies and history.

Stephen Permalink
November 08, 2013, 12:40

Very useful. good to compile to exe and run on start up.

Jeff Permalink
December 11, 2013, 19:32

I disagree with some posters. For example when you work inside a company, running a non-managed executable is not an option. Also many users don't have admin access to their PC\laptop. So sometimes Windows scripts are the only way to go.
If you are worried about the location within the filesystem, you can add a section in the script to fetch the location, and populate it instead of hardcoding.

I added 2 sections for Java and Silverlight:

set Silverlight=C:\Users\%USERNAME%\AppData\LocalLow\Microsoft\Silverlight\is
del /q /s /f "%Silverlight%"
rd /s /q "%Silverlight%"

set Java=C:\Users\%USERNAME%\AppData\LocalLow\Sun\Java\Deployment\Cache
del /q /s /f "%Java%"
rd /s /q "%Java%"

As an alternative you can always use CCleaner, or Advanced System Care.

nathan Permalink
December 13, 2013, 18:09

Perhaps you can use reg.exe instead or your custom regdelete:

Console Registry Tool for Windows - version 3.0
Copyright (C) Microsoft Corp. 1981-2001. All rights reserved

REG DELETE KeyName [/v ValueName | /ve | /va] [/f]

KeyName [\\Machine\]FullKey
Machine Name of remote machine - omitting defaults to the current machine
Only HKLM and HKU are available on remote machines
FullKey ROOTKEY\SubKey
SubKey The full name of a registry key under the selected ROOTKEY
ValueName The value name, under the selected Key, to delete
When omitted, all subkeys and values under the Key are deleted
/ve delete the value of empty value name


/va delete all values under this key
/f Forces the deletion without propmt


REG DELETE HKLM\Software\MyCo\MyApp\Timeout
Deletes the registry key Timeout and its all subkeys and values

Deletes the registry value MTU under MyCo on ZODIAC

Shit Permalink
January 28, 2014, 04:52

what the hell

Jason Cook Permalink
March 02, 2014, 04:14

I need to delete cookies for Google and Firefox for all users on a workstation. Is there a script that will do this?

Dan Ell Permalink
March 14, 2014, 18:35

Hello does anyone have a script to delete chrome and firefox cache, history, on MACHINE STARTUP?
We have hundreds of machines with hundreds of users and want to implement a script in group policy where it deletes it from every machine on startup..thanks

Nallasivam Permalink
May 21, 2014, 14:09

Thank you, dude.
I am using your code to clean all the crap that is getting dumped in my machine everyday. I am cleaning Firefox and Chrome. I really do not care about IE as I use it may be once in a year or something like that.

I scheduled it to a batch script that kills FF and Chrome before cleaning. I start everyday with fresh set of cookies. Thanks for the code.

Buchanan Permalink
July 03, 2014, 07:26

A lot has changed since this was written. None of the .bat files work anymore. Cookies from sites are hidden inside particular files now and sometimes they are encrypted. So a "Find" search will not highlight them. You will not be able to find which files they are in. For Chrome just put a link in the Bookmarks Toolbar to "chrome://settings/cookies". Then remove the cookies directly.

potaa Permalink
October 13, 2014, 06:21

can you tell me how to remotely How to delete cookies, cache and history in QQ browser? just as the same way you have done in crome,mozilla,opera and the rest

Lalit Raghav Permalink
February 14, 2015, 11:20

this code not working for google crome .please help me

David Hunt Permalink
January 25, 2016, 11:49

Can U list the batch scripts to suit NT5 (ie XP Pro). There is a huge pile of us plus equal huge number of Internet Cafes (15 to 20%) that have refused to accept Microsoft's NT6 rubbish. Ie NT6 = Vista/7/Hate/Hate.1/ and Windoze "7810. Path statement different. Thanx!

Rajendra Pradhan Permalink
September 10, 2016, 11:59

I am not coder, but sometime flushing dns worked out, and reseting netsh winsock also worked out, so now i am hanging out here to flush cookies in commandline

Leave a new comment

(why do I need your e-mail?)

(Your twitter name, if you have one. (I'm @pkrumins, btw.))

Type the word "security_246": (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.