Share this question

Welcome to Teachnovice Q&A, where you can ask questions and receive answers from other members of the community.

This is a collaboratively edited question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Chrome clean-up batch script?

0 like 0 dislike

I wrote a batch script that should automatically delete sensitive data but NOT nuke away everything.

What my (shortened) script currently looks like

set ChromeDir=%LOCALAPPDATA%\Google\Chrome\User Data

attrib +R +H +S "%ChromeDir%\Default\*Bookmarks*"
attrib +R +H +S "%ChromeDir%\Default\*Preferences*"
attrib +R +H +S "%ChromeDir%\Default\Extensions\*" /S /D
del /q /s "%ChromeDir%"
attrib -R -H -S "%ChromeDir%\Default\*Bookmarks*"
attrib -R -H -S "%ChromeDir%\Default\*Preferences*"
attrib -R -H -S "%ChromeDir%\Default\Extensions\*" /S /D

What my script should do

Delete everything except bookmarks, preferences and extensions

What my script does

Delete everything except bookmarks and extensions

The preferences that I want to save (default download path, default home page, bookmarks always visible etc.. everything you find under the (extended) settings) are somehow not in the Preferences file.

But where are they? How can I improve the script?

asked Jan 19, 2015 by Marc Mosby  

2 Answers

0 like 0 dislike

These settings are in the Preferences file, in JSON format.

Location of this configuration file is
Linux : /USER_HOME_FOLDER/.config/chromium/Default/Preferences
Windows : C:\Users\<user>\AppData\Local\Google\Chrome\User Data\Default\Preferences

For example, the default download path looks like that :

"download": {
      "default_directory": "CURRENT_PATH_OF_YOUR_DOWNLOAD_FOLDER",
      "directory_upgrade": true,
      "extensions_to_open": "",
      "prompt_for_download": false

The preference key for default download directory may seem to have disappeared from that file, because Chrome seems to not include it in the file if its value is Chrome's default value.

There are tools for manipulating JSON files in the language of your choice :

Parsing JSON File Java and JSON Manipulation in Java – Examples
C++ : JsonCpp
Intro to manipulating JSON file from PERL scripts

The above are just some examples I found at random (not necessarily the best references).

answered Jan 19, 2015 by harrymc  
0 like 0 dislike

Those settings are in next text files that contain JSON markup (JavaScript Object Notation format):

Secure Preferences

Browsing history with sensitive data are stored in next files (some of these files are used to be locked when Google Chrome browser is active, and could stay locked even if Continue running background apps when Google Chrome is closed switch is on in settings):

SQLite databases (and related *-journal files):

Extension Cookies
Login Data
Network Action Predictor
Origin Bound Certs
Top Sites
Web Data

Files in unknown format with SNSS file signature, cf. src/chrome/browser/sessions/

Current Session
Current Tabs
Last Session
Last Tabs

Files in unknown format:

Visited Links
History Provider Cache

The README file contains next caveat: Google Chrome settings and storage represent user-selected preferences and information and MUST not be extracted, overwritten or modified except through Google Chrome defined APIs.

answered Jan 19, 2015 by JosefZ