Forum Discussion

steelea's avatar
steelea
Copper Contributor
Jul 11, 2022

Microsoft Edge Cache Removal Script

Good Morning, Trying to find a way to automate a cache and cookie removal for Microsoft Edge (Chromium). I have reviewed documentation, github, reddit, and other items but there are no true automations to remove cache and cookies. Everything I find leads back to manually clearing within Edge. With internet exporer and the non chromium edge you were able to create scripts, which I have. Any help would be appreciated. 

8 Replies

  • Fritzmm's avatar
    Fritzmm
    Copper Contributor

    steelea 

    The simple solution is to clear the Default Folder under the users profile.   LIke Google Chrome the Edge brower puts all the user data in one location.  Below should help you create a a batch file.  You first kill the tasks for Edge and clear the "Default" folder.   You can go up a level a few folder levels to %localappdata%\Local\Microsoft\Edge\User Data.  However, I found the Default folder the most useful.   If you use One Drive to save favorites you shoud be safe to use the below.  If not you could backup favorites but copying the htm file under the default fold somewhere and copy it back after clearing folder.  Hope this helps

    Copy to notepad and save as .cmd or .bat

    taskkill /f /IM msedge.exe
    taskkill /f /IM msedgewebview2.exe
    rmdir /q /s "%localappdata%\Microsoft\Edge\User Data\Default"

  • Bipin-prakash's avatar
    Bipin-prakash
    Brass Contributor
    Here is the setting steelea was referring to.
    https://support.microsoft.com/en-us/microsoft-edge/delete-cookies-in-microsoft-edge-63947406-40ac-c3b8-57b9-2a946a29ae09

    Delete cookies every time you close the browser:
    In Edge, select Settings and more > Settings > Privacy, search, and services.

    Under Clear browsing data, select Choose what to clear every time you close the browser.

    Turn on the Cookies and other site data toggle.

    Once this feature is turned on, every time you close your Edge browser all cookies and other site data will be deleted. This signs you out of most sites.

    If you need a script, here is a starting point

    https://gist.github.com/mark05e/745afaf5604487b804ede2cdc38a977f

    Hope this helps!
    Best,
    bp
    • steelea's avatar
      steelea
      Copper Contributor
      Hey, I've started out on the scipt and modified the entries, even tried removing all the default edge folders, no luck.
  • josh_bodner's avatar
    josh_bodner
    Silver Contributor
    There's a setting to remove all that data automatically when the browser closes. Would that be sufficient?
    • steelea's avatar
      steelea
      Copper Contributor

      josh_bodner Sadly that would not work. Trying to build out something users can use as they want to clear Edge cache as needed. I proposed that solution and it wasn't the one. Will have to have something that is easily deployable to an end user as a package. 

      • bipinprakash's avatar
        bipinprakash
        Brass Contributor
        Are you looking for an executable or a script like a batch file? Are you able to try the script I have linked above? You can also try to convert the powershell script to a batch file using something like this https://community.idera.com/database-tools/powershell/powertips/b/tips/posts/converting-powershell-to-batch
        Best.
        bp

Resources