Add website to exclusion list edge://settings/clearBrowsingDataOnClose


WinFan

New member
Local time
10:04 PM
Posts
9
OS
Windows 11
In Microsoft Edge Settings a website be added to a list at edge://settings/clearBrowsingDataOnClose so that the site's cookies are not cleared when Edge is closed. How can a site be added to this list using PowerShell or a command - i.e. programmatically/automated?
 

My Computer

System One

  • OS
    Windows 11
Just for feedback, here's the batch file solution created.
Edge is configured to delete ALL cached data every time it closes, except for the cookies for about 20 sites. These entries are tedious to enter manually when Windows is reinstalled. The batch file below automates this.

Batch:
@echo off
rem Add websites to Edge list of sites not to clear cookies for when closing.

echo Close Edge before adding sites
pause

cd "%LocalAppData%\Microsoft\Edge\User Data\Default"
set EdgeSettingsFile=Preferences

call :AddFirstSite 192.168.1.1
call :AddAnotherSite 192.168.1.4
call :AddAnotherSite localhost
call :AddAnotherSite [*.]apple.com
call :AddAnotherSite [*.]live.com
call :AddAnotherSite [*.]microsoft.com
call :AddAnotherSite [*.]microsoftonline.com
call :AddAnotherSite [*.]youtube.com
goto :end

rem First site does not have a comma at the end (of the "bar" variable string).
:AddFirstSite
set foo=\"clear_browsing_data_cookies_exceptions\":{}
set bar=\"clear_browsing_data_cookies_exceptions\":{\"%1,*\":{\"last_modified\":\"13316715107817621\",\"setting\":1}}
echo %1%
powershell -Command "(gc %EdgeSettingsFile%) -replace '%foo%', '%bar%' | Out-File -encoding ASCII %EdgeSettingsFile%"
exit /B

:AddAnotherSite
set foo=\"clear_browsing_data_cookies_exceptions\":{
set bar=\"clear_browsing_data_cookies_exceptions\":{\"%1,*\":{\"last_modified\":\"13316715107817621\",\"setting\":1},
echo %1%
powershell -Command "(gc %EdgeSettingsFile%) -replace '%foo%', '%bar%' | Out-File -encoding ASCII %EdgeSettingsFile%"
exit /B

:end
pause
start "C:\Program Files\Notepad++\notepad++.exe" %EdgeSettingsFile%
 

My Computer

System One

  • OS
    Windows 11

Latest Support Threads

Back
Top Bottom