How to clear Microsoft Edge browser cache programmatically?

Does anyone know how to clear the cache of Microsoft Edge programmatically? (either .Net, script, command line, deleting files)

Upvotes: 6

Views: 23857

Answers (3)

Christopher K
Christopher K

Reputation: 71

The location given above I think is wrong. Below is the location for cookies, history and Cache.

directory: C:\Users%username%\AppData\Local\Microsoft\Edge\User Data\Default\Cache

file: C:\Users%username%\AppData\Local\Microsoft\Edge\User Data\Default\Cookies

file: C:\Users%username%\AppData\Local\Microsoft\Edge\User Data\Default\History

Upvotes: 7

Moe Hussein
Moe Hussein

Reputation: 11

in python you can do the following

def _edgeClearTemp():

    appdata_location = os.environ.get('LOCALAPPDATA')
    _edgeTempDir = r"{0}\Packages\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\AC".format(
        appdata_location)
    _edgeAppData = r"{0}\Packages\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\AppData".format(
        appdata_location)

    try:
        os.system("taskkill  /F /IM MicrosoftEdge.exe")
    except:
        pass
    try:
        os.system("taskkill  /F /IM dllhost.exe")
    except:
        pass
    if os.path.exists(_edgeTempDir):
        for directory in os.listdir(_edgeTempDir):
            if directory.startswith('#!'):
                shutil.rmtree(
                    os.path.join(_edgeTempDir, directory), ignore_errors=True)

    if os.path.exists(_edgeAppData):
        shutil.rmtree(_edgeAppData, ignore_errors=True)

Upvotes: 0

kissson
kissson

Reputation: 118

Go to:

%LOCALAPPDATA%\Packages\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\AC\

And delete folders that start with #!.

Upvotes: 3

Related Questions