Clear Cache in Chrome - Powershell or Cmd Prompt

I have a process that runs for a bit and unfortunately I see chrome crashing with “Aw Snap”.

In order to overcome this issue I am trying to clear the cache periodically via a Powershell or cmd line. I don’t want to use the screen so it appears seamless to the end user. I tried to use the link below with little luck Clear Cache in Chrome

Any guidance would be much appreciated.


Below PowerShell script should work.
It deletes the contents of the Cache folder in %LocalAppData%\Google\Chrome\User Data\Default\Cache
Please note, this will kill chrome first.

taskkill /F /IM "chrome.exe"
Start-Sleep -Seconds 5
$Items = @('Archived History',
            'Login Data',
            'Top Sites',
            'Visited Links',
            'Web Data')
$Folder = "$($env:LOCALAPPDATA)\Google\Chrome\User Data\Default"
$Items | % { 
    if (Test-Path "$Folder\$_") {
        Remove-Item "$Folder\$_" 

Thank you.

I will try and keep you posted

this one looks fancy and does for more browser in case you ever need…

When I am trying above code I am getting below error . I changed type argument to string then it’s working.