clear cache of browser by command line

149,117

Solution 1

Here is how to clear all trash & caches (without other private data in browsers) by a command line. This is a command line batch script that takes care of all trash (as of April 2014):

erase "%TEMP%\*.*" /f /s /q
for /D %%i in ("%TEMP%\*") do RD /S /Q "%%i"

erase "%TMP%\*.*" /f /s /q
for /D %%i in ("%TMP%\*") do RD /S /Q "%%i"

erase "%ALLUSERSPROFILE%\TEMP\*.*" /f /s /q
for /D %%i in ("%ALLUSERSPROFILE%\TEMP\*") do RD /S /Q "%%i"

erase "%SystemRoot%\TEMP\*.*" /f /s /q
for /D %%i in ("%SystemRoot%\TEMP\*") do RD /S /Q "%%i"


@rem Clear IE cache -  (Deletes Temporary Internet Files Only)
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8
erase "%LOCALAPPDATA%\Microsoft\Windows\Tempor~1\*.*" /f /s /q
for /D %%i in ("%LOCALAPPDATA%\Microsoft\Windows\Tempor~1\*") do RD /S /Q "%%i"

@rem Clear Google Chrome cache
erase "%LOCALAPPDATA%\Google\Chrome\User Data\*.*" /f /s /q
for /D %%i in ("%LOCALAPPDATA%\Google\Chrome\User Data\*") do RD /S /Q "%%i"


@rem Clear Firefox cache
erase "%LOCALAPPDATA%\Mozilla\Firefox\Profiles\*.*" /f /s /q
for /D %%i in ("%LOCALAPPDATA%\Mozilla\Firefox\Profiles\*") do RD /S /Q "%%i"

pause

I am pretty sure it will run for some time when you first run it :) Enjoy!

Solution 2

You can run Rundll32.exe for IE Options control panel applet and achieve following tasks.


Deletes ALL History - RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255

Deletes History Only - RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 1

Deletes Cookies Only - RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2

Deletes Temporary Internet Files Only - RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8

Deletes Form Data Only - RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 16

Deletes Password History Only - RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 32

Share:
149,117
Pradip
Author by

Pradip

Updated on July 05, 2022

Comments

  • Pradip
    Pradip almost 2 years

    I am working in media domain. I need to check every change in all leading browsers i.e. IE, Firefox, Chrome, Safari and Opera.

    To clear cache, every time i need to use Ctrl + Shift + del.

    Is there any another way to clear the cache of every web browser using command line?

  • LeFauve
    LeFauve over 8 years
    It really looks like the Firefox part will delete all profile data (bookmarks, home page, add-ons, ...) Instead of just the cache. Also if for some reason %TMP% or %TEMP% are not set, you could end up emptying the current drive...
  • Kiquenet
    Kiquenet over 8 years
    updates for october 2015 ? delete Profile date Firefox ?
  • JJS
    JJS almost 8 years
    what is erase? did you mean echo erase?
  • Mogens Beltoft
    Mogens Beltoft over 7 years
    This is valid for IE7+. IE6 does not have a ClearMyTracksByProcess entry point in InetCpl.cpl.
  • Charlie
    Charlie over 7 years
    IE6 is dead completely
  • Bernhard
    Bernhard about 7 years
    you should be aware of the "low integrity - protected mode"; see winhelponline.com/blog/clear-ie-cache-command-line-rundll32
  • Rakha
    Rakha over 6 years
    Thanks a lot for this, really cool and helpful! Works great for clearing a distant computer's IE cache with PSEXEC. Cheers
  • KHV
    KHV over 3 years
    I am using the Cache clear in Bat file, <RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 4351>. i am using this code in a RPA Automation solution, the issue is that is opening up a Pop-Up, which we are not able to handle that Pop-Up.. so is there any solution that runs in the background to clean the cache memory
  • Charlie
    Charlie over 3 years