How to relocate Chrome profile but also make new links open with the relocated profile?

I moved the chrome 'user data' directory and successfully launched the profile from here using the commandline switch --user-data-dir="E:\chrome", however, if i click a link it will open up a new instance of chrome, recreating a blank chrome profile and a new user data folder.

How can I fix that?


Solution 1:

Add a string value called "UserDataDir" under "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome" with the value of the user-data-dir that you'd like to use. Then you can start chrome.exe without arguments and launching *.html files from the file browser will open using this user-data-dir as well.

Solution 2:

I’ve been struggling with this issue since switching to Chrome when it first came out. Unfortunately Chrome is not designed (or currently intelligent enough) to include command-line arguments when it registers as the default browser.

I have submitted an issue to request that Chrome / Chromium include command-line arguments when registering as the default browser, but don’t hold your breath on it being implemented. (They are apparently not interested in fixing this.)

Tl;dr: skip next paragraph.


My first solution—read work-around—was originally to create a .REG file to manually set the command-line for each of the various places that need to be registered (for HTM* files, for HTTP* protocols, for hyperlinks, etc.) Of course that became quite untenable, especially since I used expandable strings (which are exported to REG files as unreadable / un-editable binary text) so that I could use environment variables. I don’t recommend this method.


My next (and current) solution was to create three environment variables, browser, browser_args, and browser_args_cu. The former variable simply holds the path to the browser’s EXE file. The second holds the command-line arguments for the browser (if any), while the last one holds user-specific arguments (such as the userdata folder location). Then, I simply replaced all instances where a browser needs to be registered (see list below) with the expandable string %browser% %browser_args_cu% %browser_args% -- "%1" and created a (4KB) REG file.

Now, I can register my “browser” of choice by merging my REG file just once. If I want to change my browser, I need not edit the REG file; all I have to do is change one or two environment variables (eg in System Properties), which is infinitely easier. Plus, I can run the browser with the appropriate command line anywhere, anytime by running the short command %browser% %browser_args_cu% %browser_args% -- "%1" and can even test other options by tacking them on to the end, or better, just put the variables in a batch file or shortcut (eg named browser). Then for example, to install an extension without experiencing the crippling bug that I have been trying to help fix, I can just close Chromium, then run browser --single-process or I can open the extension’s page directly like browser --single-process https://chrome.google.com/webstore/detail/….


List of places in the registry where Chrome/Chromium is set:

[HKLM\SOFTWARE\Clients\StartMenuInternet\Chromium\shell\open\command]
[HKLM\SOFTWARE\Clients\StartMenuInternet\Google Chrome\shell\open\command]

[HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe]
[HKCR\Applications\chrome.exe\shell\open\command]

[HKCR\ChromeExt\shell\open\command]
[HKCR\ChromeHTML\shell\open\command]
[HKCR\ChromiumExt\shell\open\command]
[HKCR\ChromiumHTML\shell\open\command]

[HKCR\ftp\shell\open\command]
[HKCR\http\shell\open\command]
[HKCR\https\shell\open\command]

[HKCR\MacromediaFlashPaper.MacromediaFlashPaper\shell\open\command]

[HKCR\pdf_auto_file\shell\open\command] (these two are custom for opening
[HKCR\svg_auto_file\shell\open\command]  PDF and SVG files with)