3

I'm trying to launch Chrome in PowerShell with a specific user profile (--profile-directory parameter), but it creates a new profile instead.

I've tried:

& "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --profile-directory=Foobar

& "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe --profile-directory=Foobar"

& "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe --profile-directory='Foobar'"

Start-Process "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --profile-directory=Foobar

Start-Process "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe --profile-directory=Foobar"

etc....

SturmUndDrang
  • 1,876
  • 5
  • 27
  • 47

4 Answers4

5

Maybe you have spaces in your path name. Try this:

Start-Process "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" '--profile-directory="Foo Bar"'

Or this:

& "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" '--profile-directory="Foo Bar"'

Update: Please note that you cannot just use any path, but simple names like "Foo" or "Foo Bar", denoting subdirectories of c:\Users\%USERNAME%\AppData\Local\Google\Chrome\User Data, e.g. c:\Users\%USERNAME%\AppData\Local\Google\Chrome\User Data\Foo Bar. The directory names can be slightly different depending on your OS and OS version. If they are the same on Win7 and Win10, I have no idea. My current machine is a Win10 PC.

kriegaex
  • 63,017
  • 15
  • 111
  • 202
  • I have just updated the answer with a solution for path names containing spaces. – kriegaex Mar 02 '17 at 11:35
  • And another update concerning Chrome profile folders. – kriegaex Mar 02 '17 at 11:49
  • Thanks. I've noticed that the list of users (Settings > People) is different to the folders under c:\Users\%USERNAME%\AppData\Local\Google\Chrome\User Data (i.e. they are not there). Are "people" different to "users"? – SturmUndDrang Mar 02 '17 at 14:17
  • My answer relates to Windows users. Each Windows user can create multiple Chrome profiles (people) within his realm. You can get the Windows user via `echo $env:USERNAME` and the `AppData\Local` folder via `echo $env:LOCALAPPDATA` from PowerShell. – kriegaex Mar 02 '17 at 14:19
  • 1
    If I e.g. create a new user in Chrome and call him "John Doe", the profile folder is something like "Person 1". The default user is "Default". Within the person's folder you find a text file named `Preferences` in which you find a substring like `"name":"John Doe"` by means of which you can find out which folder corresponds to which named Chrome user. But this really is not a PowerShell question anymore now, we are getting off-topic into Chrome. – kriegaex Mar 02 '17 at 14:26
  • I didn't realize that there was a disconnect between the users and their profile directory. I'm using the profile directory name instead of the user name now (e.g. user in chrome is "Foobar", profile directory is "Profile 1", "Foobar2" = "Profile 2" etc) but it is still creating a new profile. – SturmUndDrang Mar 02 '17 at 15:14
  • Then you are making a mistake and maybe have not carefully read the details in my answer or the comments. It definitely works, I tested it several times. – kriegaex Mar 02 '17 at 15:47
  • It wasn't working because I was using a variable that wasn't expanded. I'll mark your answer as correct – SturmUndDrang Mar 02 '17 at 16:09
0

I was still having issues with getting the powershell Start-Process command to launch chrome with multiple flags, probably because the browser versions are different 2+ years later. For me, with Windows 10 Version 1902, Chrome Version 76.0.3809.132 (Official Build) (64-bit)

Start-Process "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" -disable-web-security, --disable-gpu, --user-data-dir=~/chromeTemp

Adding the commas and using "chromeTemp" rather than "/path/to/User Data" was the change that worked for me.

Chris Wood
  • 63
  • 1
  • 5
0

Try running below commnad. This will help you to launch the chrome as different user from commandline without going through a GUI prompt. It is good by creating a .bat file and saving your credentials.

runas /user:John C:\Program Files (x86)\Google\Chrome\Application\Chrome.exe"
0

This works for a new profile from powershell

start-process Chrome "http://localhost:9876/debug.html",'--profile-directory="Profile 4"'
SuperMar1o
  • 670
  • 8
  • 23