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?

Pradip
  • 1,317
  • 4
  • 21
  • 36

2 Answers2

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!

Aljaz - aly
  • 256
  • 3
  • 2
  • 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 05 '15 at 00:39
  • updates for october 2015 ? delete Profile date Firefox ? – Kiquenet Oct 29 '15 at 22:13
  • what is erase? did you mean echo erase? – JJS Jun 29 '16 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

Charlie
  • 22,886
  • 11
  • 59
  • 90
  • 1
    This is valid for IE7+. IE6 does not have a ClearMyTracksByProcess entry point in InetCpl.cpl. – Mogens Beltoft Aug 11 '16 at 09:12
  • 2
    IE6 is dead completely – Charlie Aug 11 '16 at 10:56
  • 1
    you should be aware of the "low integrity - protected mode"; see http://www.winhelponline.com/blog/clear-ie-cache-command-line-rundll32/ – Bernhard Apr 04 '17 at 06: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 '17 at 15:17
  • I am using the Cache clear in Bat file, . 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 '20 at 11:39
  • Will this help ? https://stackoverflow.com/questions/32297699/hide-command-prompt-window-when-using-exec – Charlie Dec 25 '20 at 14:08