21

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?

2 Answers 2

17

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!

3
  • 1
    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...
    – LeFauve
    Sep 5, 2015 at 0:39
  • updates for october 2015 ? delete Profile date Firefox ?
    – Kiquenet
    Oct 29, 2015 at 22:13
  • what is erase? did you mean echo erase?
    – JJS
    Jun 29, 2016 at 15:50
15

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

6
  • 1
    This is valid for IE7+. IE6 does not have a ClearMyTracksByProcess entry point in InetCpl.cpl. Aug 11, 2016 at 9:12
  • 2
    IE6 is dead completely
    – Charlie
    Aug 11, 2016 at 10:56
  • 1
    you should be aware of the "low integrity - protected mode"; see winhelponline.com/blog/clear-ie-cache-command-line-rundll32
    – Bernhard
    Apr 4, 2017 at 6:14
  • 1
    Thanks a lot for this, really cool and helpful! Works great for clearing a distant computer's IE cache with PSEXEC. Cheers
    – Rakha
    Aug 11, 2017 at 15:17
  • 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
    – KHV
    Dec 24, 2020 at 11:39

Not the answer you're looking for? Browse other questions tagged or ask your own question.