Skip to content

Browsers clear cache & history windows

clear browsing history and cache for IE, Firefox and Chrome

Internet Explorer

$t_IE = "C:\Users\$env:username\AppData\Local\Microsoft\Windows\Temporary Internet Files"
$c_IE = "C:\Users\$env:username\AppData\Local\Microsoft\Windows\Caches"

$temporary_path =  Test-Path $t_IE
$check_cache =    Test-Path $c_IE
if($temporary_path -eq $True -And $check_cashe -eq $True)
{
    echo "Clean history"
    RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 1

    echo "Clean Temporary internet files"
    RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8
    (Remove-Item $t_IE\* -Force -Recurse) 2> $null
    RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2

    echo "Clean Cache"
    (Remove-Item $c_IE\* -Force -Recurse) 2> $null

    echo "Done"
}

save as IE_clean.PS1

Firefox (batch file)

@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

save as Firfox_clean.bat

rm ~/.mozilla/firefox/*.default*/*.sqlite ~/.mozilla/firefox/*default*/sessionstore.js
rm -r ~/.cache/mozilla/firefox/*.default*/*

Chrome (batchfile)

@echo off
set ChromeDir=C:\Users\%USERNAME%\AppData\Local\Google\Chrome\User Data
del /q /s /f "%ChromeDir%"
rd /s /q "%ChromeDir%"

save this file as “Chrome_clean.bat” on your local machine.
Now you have these all scripts ready to use when you want just double click on any selected script that you want to use based upon your browser but such repeated task you really do not want to do over and over.

Here we have supper simple method that you can use to automate this in Windows platform to do your job easy. You just need to put these scripts in your Start Program directory on your computer.

C:\Users\%UserName%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup

These scripts will execute automatically and clear your previous browsering history and cache every time when you start or restart your machines.