Use Apple Script to open Chrome with specific profile

I use multiple instances of the Chrome browser for different profiles, each with their own google account. I'm trying to automate a task using Applescript and Automator, and have set up Automator to feed a set of URLs to chrome, then run the following script:

    # input is the list of url's from the previous task
on run {input, parameters}

    # The below is an applescript loop
    repeat with theURL in input
        tell application "Google Chrome" to open location theURL
    end repeat

    # We must return something so we just return the input
    return input

end run

Is there away to specify that I want to open Chrome with the browser version I specify in the "Person" or profile of Chrome, i.e. as user [email protected] and not as user [email protected]?


If you're trying to open multiple windows in Google Chrome with each set to a different profile and open a bunch of tabs in each one, then the following example AppleScript code demonstrates the concept:

set myURLs to {"https://www.google.com", ¬
    "https://www.news.google.com", ¬
    "https://apple.stackexchange.com"}

set myProfiles to {"Default", "Profile 1"}

repeat with aProfile in myProfiles
    do shell script "open -na 'Google Chrome' --args --profile-directory=" & aProfile's quoted form
    delay 1
    tell application "Google Chrome"
        activate
        tell front window
            set URL of active tab to first item of myURLs
            delay 0.5
            repeat with i from 2 to count of myURLs
                make new tab at after (get active tab) with properties {URL:item i of myURLs}
                delay 0.5
            end repeat
            set active tab index to 1
        end tell
    end tell
    delay 1
end repeat 
  • Note: The value for --profile-directory= is that of the name of the folders in $HOME/Library/Application Support/Google/Chrome that corresponds to each profile, not your name.

Note: The example AppleScript code is just that and does not contain any error handling as may be appropriate. The onus is upon the user to add any error handling as may be appropriate, needed or wanted. Have a look at the try statement and error statement in the AppleScript Language Guide. See also, Working with Errors. Additionally, the use of the delay command may be necessary between events where appropriate, e.g. delay 0.5, with the value of the delay set appropriately.