cancel
Showing results for 
Search instead for 
Did you mean: 

Clear caches in chrome

JagadishPatro
Level 3
Imports System.IO
 
Module MainModule
    Sub Main()
        ClearChromeCacheAndHistory()
    End Sub
 
    Sub ClearChromeCacheAndHistory()
        Dim chromeUserPath As String = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\Google\Chrome\User Data"
 
        Dim chromeProfilePath As String = Path.Combine(chromeUserPath, "Default")
 
        If Directory.Exists(chromeProfilePath) Then
            ' Clear cache
            Dim cachePath As String = Path.Combine(chromeProfilePath, "Cache")
            If Directory.Exists(cachePath) Then
                Directory.Delete(cachePath, True)
            End If
 
            ' Clear browsing history
            Dim historyPath As String = Path.Combine(chromeProfilePath, "History")
            If File.Exists(historyPath) Then
                File.Delete(historyPath)
            End If
 
            Console.WriteLine("Chrome cache and browsing history cleared.")
        Else
            Console.WriteLine("Chrome profile folder not found.")
        End If
 
        ' Optionally, you can close the console window after clearing the cache and history.
        ' Console.ReadKey()
    End Sub
End Module

3 REPLIES 3

kez2fab
Staff
Staff

Hello @JagadishPatro,

Just looking at your post about clearing the caches in Chrome. Did you have a specific ask about the code you posted?
Are you having some problems or an issue with it?

Or maybe, this was in response to another post and it was posted accidentally?

Please let me know.

Thanks.



------------------------------
Anthony Ringot
Customer Support, Team Manager, APJ
Blue Prism
Australia / Sydney / Australia
------------------------------

i have responded to a old post as new thread .I am facing challenging in the process where need to clear chrome cache regularly.

Do you any blueprism VBO or code to clear cache and clear cookies also.



------------------------------
Jagadish Patro
------------------------------

HI Jagadish Patro,

Not sure whether you have tried the different approaches 

Clearing the browser cache:
1)  Navigate to the folder in program data and delete the respective folder if  the logged in user is default user

Also you can create a bat file and  run the bot file through bot to delete the cache: 
 Bat file name: "ChromeClearCache.bat"

"@echo off

set ChromeDir=C:\Users\%USERNAME%\appdata\Local\Google\Chrome\User Data\Default\Cache

del /q /s /f "%ChromeDir%"
rd /s /q "%ChromeDir%""


C# Code:
"public static void ClearChromeCache()
{
   Process proc = null;
   try
   {
       proc = new Process();
       proc.StartInfo.FileName = "ChromeClearCache.bat";
       proc.StartInfo.CreateNoWindow = false;
       proc.Start();
       proc.WaitForExit();
   }
   catch (Exception ex)
   {
       Console.WriteLine("Exception Occurred :{0},{1}", ex.Message, ex.StackTrace.ToString());
   }

}"

Please test  it on the machine you are intended to clear the cache. I have not used this code Instead I did by navigating the screens to clear it.

2) Spy the navigating after launching the chrome and navigate to the page to clear the cache  - I did for Edge 
3)  Write C# or Vb.net code
 



------------------------------
-----------------------
If I answered your query. Please mark it as the "Best Answer"

Harish M
Lead developer
America/New_York TX
------------------------------
----------------------- If I answered your query. Please mark it as the "Best Answer" [FirstName] [LastName] [Designation] [JobTitle] [City] [State] [Phone]