35

I use multiple Google Chrome profiles, each logged in with a different account.

What I would like to be able to do is if I open a URL in an external app (such as Mail), it would open the correct profile based on the domain.

https://personal.com would be opened in profile "Personal" https://company.com would be opened in profile "Business"

By default, Chrome uses the last opened profile.

vvondra
  • 566
  • 1
  • 5
  • 11
  • There’s a related question on [SO]:  [Can my chrome extension open a link in a different profile?](https://stackoverflow.com/q/35493163/1672723),  which, in turn, links to  [Can I create a new session in another tab or window in Google Chrome?](https://superuser.com/q/218107/150988),  which, in turn, is closed as a duplicate of  [How can I get a new browser session when opening a new tab or window on Firefox/Chrome?](https://superuser.com/q/690/150988) – Scott - Слава Україні Sep 27 '17 at 21:41

8 Answers8

6

Google provides what you need. However, this is a part of Enterprise. You can setup what the link and how it does work in GPE. The link: Configure which browsers to open with LBS . I recommend use something like google.exe --app=http://example.com --user-data-dir:/home/example/.config/chrome/ for a policy.

red
  • 61
  • 1
  • 2
6

I found it! months of search and I finally found something useful.

https://chromium.googlesource.com/chromium/src/+/refs/heads/main/chrome/common/chrome_switches.cc

The flag I was looking for is:

// Like kProfileDirectory, but selects the profile by email address. If the
// email is not found in any existing profile, this switch has no effect. If
// both kProfileDirectory and kProfileUserName are specified, kProfileDirectory
// takes priority.
const char kProfileEmail[] = "profile-email";

google-chrome --profile-email=user@domain.com
stimur
  • 181
  • 1
  • 4
  • Most probably this option would work as well: > // Selects directory of profile to associate with the first browser launched. > const char kProfileDirectory[] = "profile-directory"; – stimur Nov 16 '21 at 23:48
  • 1
    How to use this? Is this a terminal command? – T J Jul 25 '22 at 02:30
  • Yes, this is CLI parameters – stimur Jul 26 '22 at 20:00
  • @TJ for those following along at home, on MacOS, the actual full command is `'/Applications/Google Chrome.app/Contents/MacOS/Google Chrome' --profile-email=user@domain.com` – ijoseph Feb 10 '23 at 03:25
5

I got this solved using https://www.choosyosx.com/. Works perfectly for the use case I needed and even opens correctly links in native apps like Slack or Notion.

vvondra
  • 566
  • 1
  • 5
  • 11
3

I achieved something similar with the chrome extension I built, CopyTabs (https://chrome.google.com/webstore/detail/copytabs/obkbjogekcjalnaebheboejhfkamadkg). It is able to open current tabs, selected tabs or windows, in the current chrome user profile, another chrome user profile or another browser entirely.

It doesn't do exactly what's asked as in having https://personal.com open in profile "Personal" and https://company.com open in profile "Business", but if https://personal.com opens in profile "Business" it allows you to move it to profile "Personal".

I made use of chrome.exe --profile-directory="profileName" to open URLs in a selected profile from a handler that runs on the user's machine. The command makes use of the internal names of the profiles, for example --profile-directory="Profile1" instead of --profile-directory="My Name As Profile".

Hope it's useful.

Keisha W
  • 141
  • 2
  • Doesn't work for macOS :( – felixfbecker Nov 11 '19 at 08:54
  • @felixfbecker there is a relatively simple way to do this on MacOS. I tested it out and it works. Create two desktops. Put profile1 on desktop1 and profile2 on desktop2. Let's say I have a link in Slack I want to click. My work Slack account is also up on desktop1. Even if I have last used profile2, the link is opened in the profile that is currently open on desktop1. So generally, desktop1 is for work apps, and desktop2 is for personal apps. – Kevin MacDonald Aug 20 '20 at 20:27
2

I believe that Account Surfer that I've made should be able to do the things that you're looking for. Here's an overview from Windows store:

Quickly switch between accounts and browsers with Account Surfer.

Decide what account or browser to use when opening the link. Read more: https://dospolov.com/posts/handle-chrome-profiles-with-account-surfer https://trello.com/b/QOLCmlg3/account-surfer-roadmap

enter image description here

msdos
  • 121
  • 4
  • 1
    Please see [How do I recommend software in my answers?](//meta.superuser.com/q/5329/354511) Most importantly, describe **how** the software answers the question, and disclose any association that you have with the product. – G-Man Says 'Reinstate Monica' Apr 04 '20 at 14:51
2

On Windows 11 I was able to accomplish this by opening regedit and finding the following key: Computer\HKEY_CLASSES_ROOT\ChromeHTML\shell\open\command.

Default was set to this: "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --single-argument %1

I changed it to include the --profile-directory switch similar to this to open the default profile:

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --profile-directory="Default" --single-argument %1
Toto
  • 17,001
  • 56
  • 30
  • 41
jrh2004
  • 21
  • 1
  • 1
    This worked for me on Windows 10, but I had to use --profile-email="mail@example.com" – Tomek Aug 02 '23 at 12:27
1

Do NOT use an extension for this if you know how to use a cli or create a shortcut in windows. Chrome / Chromium has already 2 options:

Option 1

google-chrome --profile-directory="Profile 1"

Option 2

google-chrome --profile-email="mail@example.com"

I prefer the first option, since this also works with local profiles. It is a bit tricky to find the correct profile name. Chances are high that you first created profile is called Default and the following Profile 1, Profile 2 and so on. It is stored in the chrome user config directory, which depends on the OS you are using. For Linux it is ~/.config/chrome/Profile 1 for example. If the profile directory does not exist yet, it will just create a new profile which is kinda awesome.

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 14 '22 at 09:24
0

Seems like Browser Chooser 2 can do this on Windows. It seems to be a good alternative to the OSX exclusive app Choosy.

John
  • 109
  • 2
  • 2
    Please see [How do I recommend software in my answers?](//meta.superuser.com/q/5329/354511) Most importantly, describe **how** the software answers the question, and disclose any association that you have with the product. – G-Man Says 'Reinstate Monica' Apr 04 '20 at 14:51
  • For me, Browser Chooser 2 works perfectly to separate my private and business chrome profile. You can also define "rules" for which URL which chrome-profile should be used, exactly what I was looking for. Thank you for the recommendation @John – 2h4u May 12 '21 at 05:24
  • Also try [Browser Tamer](https://www.aloneguid.uk/projects/bt/). – Ivan G. Feb 11 '22 at 10:37