How do I start Chrome using a specified "user profile"?

169

74

I use the new built-in "Users" feature of Chrome to switch between Home/Work accounts easily. However, Chrome remembers the "last" user profile you had selected when launching new windows. This is a problem if I close down my "Home" profile last, because when I then click the Email shortcut on my taskbar, because it goes to mail.mycompany.com using my Home profile, and I'm not logged in.

I'd like to change the shortcut to the company webmail to pass a switch that tells Chrome to always start as the "Default" user, regardless of the last one used.

Note: I have tried the command-line parameter --user-data-dir=…, and this seems to do something very different, completely isolated from the Users functionality built in to Chrome. It's possible I'm using it wrong, but please test this before assuming it does the same thing and posting an answer ;-)

Danny Tuppeny

Posted 2012-01-11T08:49:04.160

Reputation: 2 249

1The "user-data-directory" contains 1 or more "profile-directorys". The first one being Default, the second one (if existent) Profile 1, then Profile 2 (I assume) and so on. So the --profile-directory=Default parameter is relative to the user data directory by default (i.e. unless it starts e.g. with a drive letter: C:\MyChromeUserData\Default). Apart from the profiles, the user data directory contains little° useful data. When browsing the web on this topic, reckon with confusing inconsistent terminology for these 2 user/profile folder levels. // ° Footnote in next comment: – Aaron Thoma – 2016-11-21T16:04:40.450

Footnote for previous comment: ° probably not problematic to lose, e.g. in case you need to merge two of them; maybe the least unimportant data is the Local State file containing your choices whether Chrome should prompt for the application with which to open certain file types. – Aaron Thoma – 2016-12-05T19:55:28.887

3

possible duplicate of Make Google chrome with specific user profile as default browser

– Synetech – 2012-07-19T19:27:27.140

2

For a Gmail shortcut in Windows: C:\Users\username\AppData\Local\Google\Chrome\Application\chrome.exe --profile-directory=Default --app=https://mail.google.com/mail/u/0

– None – 2012-07-25T15:40:21.333

Answers

175

The command line argument you're looking for is --profile-directory=Default.

Here's the complete command line for Mac OS X:

open -a "Google Chrome" --args --profile-directory=Default

Note: The open command therefore does not launch new instances, as many applications will not be able to deal with multiple instances running as the same user. However there's the -n argument to do that anyway, but it may break the application.

And for Linux:

google-chrome --profile-directory=Default

It expects the internal names of the profiles: My second profile, named "Lemonade" by Chrome, would be --profile-directory="Profile 1".

Determine the profile name by trial and error, or looking in the Local State file (see Justin Buser's answer).

On Mac OS X, the directories are located in ~/Library/Application Support/Google/Chrome. In Linux they are located in ~/.config/google-chrome. In Win7 they are located in %USERPROFILE%\AppData\Local\Google\Chrome\User Data.

Daniel Beck

Posted 2012-01-11T08:49:04.160

Reputation: 98 421

1As of 2015 Jan, this still does not work on OS X. One thing that does work is opening the application directly with the --profile-directory argument, even if the application is already running. So the problem isn't with the management of open windows so much as it is with how the Mac OS X open command interoperates with the application. – David P. Caldwell – 2015-01-27T22:50:48.323

1@DavidP.Caldwell On OS X, an application generally only runs once. The open command therefore does not launch new instances, as many applications will not be able to deal with multiple instances running as the same user. There's the -n argument to do that anyway, but it may break the application (or be actively prevented by it). – Daniel Beck – 2015-01-28T11:51:36.050

Your answer helped me in conjunction with these other answers: http://superuser.com/a/908108/74576 and http://superuser.com/a/997535/74576

– Ryan – 2016-12-30T03:56:35.480

Why doesn't --args work for user data dir? – Pacerier – 2017-09-15T11:57:35.233

Great ideas here; I have merged them all into a canned-solution. https://github.com/codemedic/bash-ninja/blob/master/gchrome

– ϹοδεMεδιϲ – 2017-11-12T20:48:36.823

6There's a super easy way to identify the profile directory: go to chrome://version and check the Profile Path. Assuming you are seeing /path/to/your/PROFILE, use --user-data-dir=/path/to/your --profile-directory=PROFILE. If your user data directory is the default location (the last paragraph in the answer) you can omit it. – yegle – 2018-11-28T18:08:20.480

I know the question is tagged as "command-line" but this pg came up in my searches so leaving a note for myself and others.

As stated in comments, the Mac solution doesn't work for me to focus already opened profile. However, using keyboard shortcut superuser.com/a/954380/219323 works! I used hammerspoon to open Chrome then initiated a keyboard shortcut to switch to profile.

hs.hotkey.bind({"cmd", "alt", "ctrl"}, "f9", function() hs.application.launchOrFocus("Google Chrome") hs.timer.doAfter(0.1, function() hs.eventtap.keyStroke("alt", "f9") end) end) – John Lee – 2019-07-11T21:03:30.037

Is it possible to pass it a full path (ie: a userDataDir used by a headless chromium build) – Ki Jéy – 2020-01-12T18:09:02.880

1Brilliant! I didn't think it was possible (after searching for weeks, even going through the code repo). Great to not have to worry about the order I close the browsers in now :) – Danny Tuppeny – 2012-01-11T13:15:56.610

2@DannyTuppeny I got it from the source file after a few failed experiments. But you're right, googling for it is definitely difficult as everyone seems to use the other argument... – Daniel Beck – 2012-01-11T14:35:06.173

2As of Nov 2013 this doesn't seem to work in Chrome for Mac. If all sessions are closed the parameter is honored, but after initial opening Chrome chooses same user profile regardless of parameter. (I run as non-admin user). – John Faughnan – 2013-11-04T04:31:23.210

3It's always a good idea to use a bundle identifier instead of the app name, as people sometimes rename their apps. (I renamed mine "Chrome" and the command above does open it at all.) open -b com.google.Chrome --args --profile-directory=Default – interestinglythere – 2014-01-02T19:20:16.177

56

GUI method with proper icon (for Windows)

  1. Type chrome://settings/ in address bar (or Menu > Settings)
  2. Scroll down to Users section
  3. Select the user marked (current) & click Edit button enter image description here
  4. Now click Add desktop shortcut enter image description here

Optional Switch to any other profile & repeat steps 1-4

This creates a shortcut icon to your profile with the correct picture in the icon too. You can drag multiple profiles to your Windows taskbar. The shortcut on Windows 7 icon points to

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --profile-directory="Default"
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --profile-directory="Profile 1"
and so on...

user

Posted 2012-01-11T08:49:04.160

Reputation: 949

5Does not work for Linux. No button "Add deskop shortcut" – Heinrich Hartmann – 2015-11-06T00:55:06.433

2@HeinrichHartmann True, added Windows to the answer. Have to fallback on command line shortcuts for linux. – user – 2015-11-06T03:51:33.013

An alternative, at least in win 10 pro, to dragging the newly created Chrome profile icon to the taskbar is to right click the desktop icon, then select "pin to taskbar" (unpin and re pin if already pinned). it seems the desktop icon reference to the programs file system is more promising than opening profiles and pinning all through the taskbar. – user289394 – 2017-05-11T13:43:37.817

This doesn't work when using the --user-data-dir flag – SpareBytes – 2017-11-29T18:23:21.487

On the current version of chrome (v65) there is now a toggle switch below the name and above the profile pictures with the words "Show desktop shortcut". – Keven – 2018-03-07T22:47:42.607

There is no "Users" section on the settings page. – Slava Fomin II – 2020-01-13T00:56:56.287

13

Another, albeit less convenient method of choosing which profile will launch is to edit the Local State file in the Chrome User Data directory and search for "last_used": if you change the value it lists to a different Profile that's the one that will open the next time you launch chrome normally (unless of course you're using the switch mentioned above).

I only mention this in case anyone is interested in a more in-depth solution, that Local State file contains a JSON formatted list of settings that some might find useful.

Justin Buser

Posted 2012-01-11T08:49:04.160

Reputation: 1 147

5

Specifically the JSON object is .profile, thus if you have a tool like JQ you can even easily parse this out via: cat ~/.config/google-chrome/Local\ State | jq .profile to quickly see metadata on the profile like "user_name" (your Google Apps username for the profile), "name", etc.

– Brian Redbeard – 2016-11-04T01:48:05.197

6

--profile-directory is useless if you already have another profile opened or the last window you closed is attributed/was logged in with another profile.

I have app shortcuts with one profile. The apps shortcuts have --profile-directory="Profile 3" plus the --app="..

The default profile shortcut has --profile-directory="Default".

Both profiles get messed up. Extensions and the default shortcut that I use for daily browsing.

Marius

Posted 2012-01-11T08:49:04.160

Reputation: 71

2I've had no issues - I just made sure all my shortcuts have the --profile-directory, so they'll all start with the profile I want :) – Danny Tuppeny – 2012-01-24T19:10:01.043

1I agree with Danny, you don't know what you're talking about. I have 6 profiles and a shortcut for each on my using this method and I can launch any or all of them regardless of whether or not chrome is already running. – Justin Buser – 2012-06-13T11:53:53.287

2@JustinBuser can you still do this in chrome 23? After chrome is open for me, I can't seem to launch a new window or change the profile with these switches. – y3sh – 2012-10-03T19:08:21.457

3

I've just tested this with 4 profiles with Chrome Version 22.0.1229.94 m:

Respectfully, I think the confusion is this:

  • If you close all instances of chrome and then launch Chrome with a simple chrome.exe without any switches, then this new instance that is launched will open with the profile of the very last Chrome window/instance that was closed.

  • If however, you click on a shortcut that you've created using the above --profile-directory method, an instance/window with the appropriate login regardless of which window(s)/ instances/ profiles are currently running, and/or which was the last one shutdown.

  • Flak DiNenno

    Posted 2012-01-11T08:49:04.160

    Reputation: 4 450

    1

    This still works with Chrome Windows as of 4/24/2013. I created a shortcut for each of the 3 profiles I routinely switch between, and I assigned each shortcut a unique "shortcut key".

    One additional nicety -- your profile user icon is in the profile subdirectory, ex: %USERPROFILE%\AppData\Local\Google\Chrome\User Data\Profile 1. I assigned my profile user icon to the windows shortcut.

    I can't reliably put the 3 shortcuts separately on the Win7 taskbar though; win 7 seems to lose count after 2.

    John Faughnan

    Posted 2012-01-11T08:49:04.160

    Reputation: 277

    0

    As of April 2016 on Yosemite, I was able to locate Google Apps for all of my 15 Google Profiles (yes, 15). Some were in ~/Applications/Chrome Apps, though we have been told that these are going away.

    To find all of them however I had to do this:

    1. Go to ~/Library/Application Support/Google/Chrome.
    2. In Spotlight search on kind:app
    3. Find 300kb "Applications" with names like Gmail (username).
    4. Copy the ones you want and rename them, then put in your Applications folder of choice.

    John Faughnan

    Posted 2012-01-11T08:49:04.160

    Reputation: 277

    0

    I think the newer version of chrome has already solved this problem. When you signin with a new user in Chrome, it automatically creates a shortcut icon for that user on your desktop.

    user590849

    Posted 2012-01-11T08:49:04.160

    Reputation: 255

    1This seems to be only in Windows, right? – Gray -- SO stop being evil – 2018-06-05T14:43:16.877