Jump to content

Hello! Looking for some help with a batch file. I do Tech Support for a large company and quite simply got tired of having to repeatedly clear the cache for 200+ users on a nearly daily basis. Though we only use IE/Google Chrome, I made it able to do Firefox as well. It has worked great until we switched to Windows 10 as a company. It is no longer preserving the favorites in Google Chrome which is no bueno. The way I handled favorites before was I moved the favorites out of their folder with all the files that would be deleted and then moved the favorites back in after everything was deleted.

 

My code is below.

 

taskkill /F /IM chrome.exe /T > nul
move /y "C:\Users\%USERNAME%\AppData\Local\Google\Chrome\User Data\Default\bookmarks"  "C:\Users\%USERNAME%\Documents"

move /y"C:\Users\%USERNAME%\AppData\Local\Google\Chrome\User Data\Default\bookmarks.bak"  "C:\Users\%USERNAME%\Documents"

set ChromeDir=C:\Users\%USERNAME%\AppData\Local\Google\Chrome\User Data

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

rd /s /q "%ChromeDir%"

md "C:\Users\%USERNAME%\AppData\Local\Google\Chrome\User Data"

md "C:\Users\%USERNAME%\AppData\Local\Google\Chrome\User Data\Default"

move /y "C:\Users\%USERNAME%\Documents\bookmarks"   "C:\Users\%USERNAME%\AppData\Local\Google\Chrome\User Data\Default"

move /y "C:\Users\%USERNAME%\Documents\bookmarks.bak"   "C:\Users\%USERNAME%\AppData\Local\Google\Chrome\User Data\Default"

RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8

RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2

taskkill /im "firefox.exe"

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



 

Link to comment
https://linustechtips.com/topic/1051222-cache-clearing-batch-file-help-win10/
Share on other sites

Link to post
Share on other sites

A few basic steps to help diagnose the issue would be

 

  1. Even if the overall behavior is still not what you want, verify that each command is working correctly, and not being blocked by permissions or something like that
  2. I assume you're running this as a scheduled task.  Does it work if you run the batch file by doubleclicking on it, but not when you run it via the task, or vice versa?  If so there's likely a permission issue.  Try running the task under a different account and make sure the account has permission to logon as a service.
  3. Close Chrome and move the bookmarks by hand then start it back up.  Do you see the bookmarks still?  If so, then likely you're not in the right spot.

 

Also, don't forget that Chrome will now also save the bookmarks in the google account of the person logged on.  That might be what the cache clearing is interfering with.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×