Clear Cache in Chrome

Hi Vijay,

Start-Sleep -Seconds 5
$Items = @(‘Archived History’,
‘Cache*’,
‘Cookies’,
‘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$

}
}

I am using above power shall script to clear chrome cache.
I am able to clear up to some cache files but also getting below error.

Access to the path ‘C:\Users\Machinename\AppData\Local\Google\Chrome\User Data\Default\Cache\data_0’ is denied.
Access to the path ‘C:\Users\Machinename\AppData\Local\Google\Chrome\User Data\Default\Cache\data_1’ is denied.

data files are not able to clear.
Please help me to resolve this issue.

Just a remark from my side:
why are you not using incognito tabs in the first place to not save any cache/cookies from the session?

Why not use Auto-Delete Cache in the browser by default? In an enterprise scenario you can easily handle this by config or policy.

1 Like

It is not working for c#

you are getting this error because Chrome is open. The powershell script will not work if Chrome is open. I would do a kill chrome before you start the clear cache. Also, in your script you will need a recurse.

Hi,

This works for me:

  • send hotkey Ctrl+Alt+Del
  • click image “Clear data”

Since Google does not let the settings selector to be captured, this is the only solution feasible I can think of at the moment.
good luck!

Hi All

We can clear cache and cookies without send hot key by using delete file activity

Go to program files x86 → Google chrome-> cache/cookies folder

Any doubts ping me again ll help you

Thanks
Ashwin.S

I was getting an error as
“The item at C:\Users<Username>\AppData\Local\Google\Chrome\User Data\Default\Cache\Cache_Data has children and the Recurse parameter was not specified. If you continue, all children will be removed with the item. Are you sure you want to continue? —> System.Management.Automation.Host.HostException: A command that prompts the user failed because the host program or the command type does not support user interaction.”

This worked for me.
//The first line is if chrome is open it will kill it else it will still proceed with it.

ps chrome -ErrorAction SilentlyContinue | kill -PassThru
Start-Sleep -Seconds 5
$Items = @(‘Archived History’,
‘Cache*’,
‘Cookies’,
‘History’,
‘Login Data’,
‘Top Sites’,
‘Visited Links’,
‘Web Data’)
$Folder = “$($env:LOCALAPPDATA)\Google\Chrome\User Data\Default”
$Items | % {
if (Test-Path “$Folder$") {
Remove-Item -Recurse -Force "$Folder$

}
}

1 Like

This works…

Hi, does this work in the PIP mode and Will it clear the cookies of the browser in main session too if I run it in PIP?

I dont need it to clear cookies in the main session

Thank you

I am getting this error:

Hi, i’ve been using this code to clear cache.
If it doesnt work yo can also try starting your process in incognito.

Clear_Chrom_Cache.zip (4.2 KB)

Try Below script It works
Please enable below option in Invoke activity and close browser before executing.

$Items = @(‘Archived History’,
‘Cache*’,
‘Cookies’,
‘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$
” -Recurse -Force -EA SilentlyContinue -Verbose
}
}