How to change the default browser to Google Chrome?

jhuls
Contributor III

I've received a request to change a lab of iMacs over to Google Chrome as the default browser. The lab is currently equipped with Snow Leopard and Chrome is already installed. Safari is the default browser at the moment.

I've attempted to do some internet searches on how to do this but come up short since I'm wading through tons of sites explaining how to change it via the gui. Has anyone done this via Casper or are aware of how I could implement such a solution? This needs to be something I can automate as I can see this getting requested in other labs soon.

Thanks in advance.

2 ACCEPTED SOLUTIONS

eukatc
New Contributor II

@jhuls you can set it up in the JSS as a managed preference (Managed Preference > Internet Configuration > Default Web Browser) and then if not done already setup the iMacs in that lab into a Static Computer group and just scope the managed preference to the lab.

View solution in original post

mark_sampers
Contributor

I believe the plist that holds the default browser setting is ~/Library/Preferences/com.apple.LaunchServices.plist. We create a modified dmg of this plist and deploy it to FEU and FUT. As you state, there are usually several options to complete a single task. Good luck. -Mark

View solution in original post

40 REPLIES 40

eukatc
New Contributor II

@jhuls you can set it up in the JSS as a managed preference (Managed Preference > Internet Configuration > Default Web Browser) and then if not done already setup the iMacs in that lab into a Static Computer group and just scope the managed preference to the lab.

jhuls
Contributor III

Thanks...somehow I missed that.

After posting this I did find a command line app called duti that looks like it might let me do the same thing but I'll definitely explore both to see which one I prefer.

Thanks again!

mark_sampers
Contributor

I believe the plist that holds the default browser setting is ~/Library/Preferences/com.apple.LaunchServices.plist. We create a modified dmg of this plist and deploy it to FEU and FUT. As you state, there are usually several options to complete a single task. Good luck. -Mark

jhuls
Contributor III

I just came across this on my Mavericks install while snooping around. Deploying via dmg is an interesting option as well. Thanks!

Almost all of my administration experience has been in the Windows world so I'm still wrapping my head around how things get done on this side of the fence and what my options are. I think I need to find a good resource for learning more about preferences and plists and what's in them. In the Windows world group policies and preferences are pretty simple to work with and fairly well explained and if it's not enough you just dig into the registry. Here it seems thus far it's not quite as intuitive on the administration side.

Thanks again!

greatkemo
Contributor II

I know this is an old post, but maybe just maybe someone like me is stuck with Yosemite, and comes across this.

Run the following lines in a login script to set the browser as default for each user.

Assuming Chrome is already installed:

open -a "Google Chrome" --args --make-default-browser
sleep 1
sqlite3 /Library/Application Support/com.apple.TCC/TCC.db "REPLACE INTO access VALUES('kTCCServiceAccessibility','com.apple.loginwindow',0,1,1,NULL);" 
osascript -e 'tell application "System Events" to tell process "CoreServicesUIAgent" to tell window 1 to click button 1' >/dev/null 2>&1
sqlite3 /Library/Application Support/com.apple.TCC/TCC.db "delete from access where client='com.apple.loginwindow';"

Very subtle solution and works quite nicely.

Kamal

bentoms
Release Candidate Programs Tester

This is exactly the thing that duti is for.

Install the binary, then run something like the below triggered via a launchAgent.

duti -s com.google.chrome public.html all

jhuls
Contributor III

Thanks @greatkemo and @bentoms . I just got a lab in of Yosemite based systems and have to deal with this now. Your posts are timely...I'll give them a try...thanks!

aaronbwcollins
New Contributor III

It's worth mentioning the in El Capitan they added another table so you just add an additional NULL:

open -a "Google Chrome" --args --make-default-browser
sleep 1
sqlite3 /Library/Application Support/com.apple.TCC/TCC.db "REPLACE INTO access VALUES('kTCCServiceAccessibility','com.apple.loginwindow',0,1,1,NULL,NULL);" 
osascript -e 'tell application "System Events" to tell process "CoreServicesUIAgent" to tell window 1 to click button 1' >/dev/null 2>&1
sqlite3 /Library/Application Support/com.apple.TCC/TCC.db "delete from access where client='com.apple.loginwindow';"

MST
Contributor

sorry to interrupt the discussion since we have 10.10.4 script runs without any errors but still safari is default browser and when I click on the Chrome it asks if I want to make it default.

tcandela
Valued Contributor II

@eukatc I know this post has been a few years now, but would your solution still work today? on Sierra ? wanting to set Google Chrome as the default browser?

I am trying your solution, using the below value to set the managed preferences --> internet configuration --> default web browser

it doesn't seem to do anything anyways. I scope it to a test group of 2 computers and I check system preferences --> general -- Safari is still listed as the default web browser.

here is another question; whats the point of setting the default web browser? the user can use whatever browser they want !! we have Safari,Firefox and Google Chrome installed!! how would setting the default web browser help if a user prefers to use a different browser over the browser I want to set as default ???

We have a certain Web application that works better in Google Chrome versus Safari -- so this is why I want to set the default browser. But if the user uses Safari to access that web application, what is the point of setting Google Chrome as the default browser?

"/Applications/Google Chrome.app"

eukatc
New Contributor II

@tcandela haven't tested it on Sierra but don't see no reason why it wouldn't work, thats the right file path for the config

mark_sampers
Contributor

In macOS 10.12 the plist that holds the default browser settings has moved to: ~/Library/Preferences/com.apple.LaunchServices/com.apple.LaunchServices.plist.
-Mark

tcandela
Valued Contributor II

@mark.sampers I went to that location and the com.apple.LaunchServices folder was empty, so I went to system preferences --> General and changed the default web browser from Safari to Google Chrome. Upon making this change, immediately a file was created in this empty folder

com.apple.launchservices.secure.plist

what process did you do to create your dmg? I don't need it to mess with FEU just want it setup for newly configured macs from this point on. so would it be FUT ?

do i just drag that .plist file into Composer ?

mark_sampers
Contributor

@tcandela I used the same process you described. FUT would work. I normally use check both FEU and FUT in case a package needs to be pushed out before a re-image.

tcandela
Valued Contributor II

@mark.sampers thanks, I am clear on the FEU/FUT option i want to select, but in order to create the dmg do i just simply drag the file com.apple.launchservices.secure.plist from the com.apple.LaunchServices folder into composer

mark_sampers
Contributor

@tcandela Yes, drag the plist into composer and create the dmg. Note: I normally create the package using a local management account that is part of our base macOS. (Doing so allows the package to be installed properly during imaging. At least in our work flows.)

tcandela
Valued Contributor II

@mark.sampers ok. dmg created.

When saving it into Casper Admin would i check the box INSTALL ON BOOT DRIVE AFTER IMAGING ?

tcandela
Valued Contributor II

@mark.sampers ok. dmg created.

When saving it into Casper Admin would i check the box INSTALL ON BOOT DRIVE AFTER IMAGING ?

jrippy
Contributor II

You could also try using lsregister. I don't have specific examples as I've just started looking into it as well but there is a frontend called duti for it.
Details here: http://krypted.com/mac-security/lsregister-associating-file-types-in-mac-os-x/

mark_sampers
Contributor

I normally don't. (Again, this is the reason I create the package using a local management/admin account that is part of our base OS.) Your environment may be different. You'll want to test the package and adjust it if needed. Good Luck.

tcandela
Valued Contributor II

@mark.sampers i tested it via creating a policy, then i manually created 2 accounts, logged into each account and checked system preferences --> General and the default web browser set to Google Chrome

I created a web link in a word document, Google Chrome opened, but then i was greeted with 2 popups

1 - this is an application open from the internet, do you want to open it .............. you know that popup message
2 - do you want to make Google Chrome as your default browser

how would i get rid of these 2 ugly popups ?

tcandela
Valued Contributor II

@mark.sampers i tested it via creating a policy, then i manually created 2 accounts, logged into each account and checked system preferences --> General and the default web browser set to Google Chrome

I created a web link in a word document, Google Chrome opened, but then i was greeted with 2 popups

1 - this is an application open from the internet, do you want to open it .............. you know that popup message
2 - do you want to make Google Chrome as your default browser

how would i get rid of these 2 ugly popups ?

mark_sampers
Contributor

@tcandela Those pop-ups are probably related to your Google Chrome package. When creating a Google Chrome package, I will normally launch Chrome and adjust settings before packaging with Composer. Depending on your needs, the "Pre-installed Software" option in Composer may help package Google Chrome.

tcandela
Valued Contributor II

@mark.sampers I see now. My google chrome installs on each computer after enrollment using a script that was pulled from the jamf nation scripts. It runs monthly to check to see if each computer is running the latest version, if not it updates it with the latest version.

Since this computer was just enrolled, and the first time google chrome was run from that user account that is why those pop-ups appeared.

I like using this script over having to make new package each time

jrippy
Contributor II

Not sure if you want this or not, but if you want Chrome to autoupdate, below is a script I found from Hannes Juutilainen. https://github.com/hjuutilainen/adminscripts/blob/master/chrome-enable-autoupdates.py

lsegura
New Contributor II

@greatkemo hi, the script worked, but do you have any idea how can I add some bookmarks to the gogle chrome using a script?

greatkemo
Contributor II

@lsegura best thing to do with bookmarks is package them from admin machine with composer and deploy them to FUT and FEU.

The path to the bookmarks you need to package I believe is ~/Library/Application Support/Google/Chrome/Default/Bookmarks

Kamal

HelpDeskWarrior
New Contributor II

Hi @bentoms I tried the command on El Capitan from your post and got the error 'failed to set com.google.chrome as handler for public.HTML (error -54)

'duti -s com.google.chrome public.html all'

stevewood
Honored Contributor II
Honored Contributor II

@HelpDeskWarrior I just spent 4 days trying to set Chrome as default. I tried everything from:

I found several articles talking about setting the default browser, including this discussion, but none of the methods worked. Alan Siu had a good post over here about changing Launch Services, and at the bottom indicates that Google Chrome just cannot be changed. I tried his script, ChromeDefaultBrowser.sh, but again, had no luck.

My goal was to do two things: 1) set Chrome as default, and 2) get rid of the welcome dialog and all other dialogs on the first run. I was able to accomplish the second by utilizing the Python script that @daz_wallace came up with in his blog post How to stop first run messages in Google Chrome.

Unfortunately, to meet my first goal I had to do something I hate doing: capture the LaunchServices settings via Composer. Actually, I just packaged up the settings, so I could have used my preferred tool, Packages, but Composer was easier in this case.

Unless someone has newer information, or another method to set the default browser without getting any pop-up dialogs, I'll just trudge forth with replacing the LaunchServices plist for the user.

HelpDeskWarrior
New Contributor II

@stevewood Thanks for a detailed response, it's a relief to know that this is not such an easy task. Can you expand more on what you mean by capturing launch services? I am familiar with using composer. Does this actually work?

smithjw
New Contributor III

@stevewood I'm really hoping you find a scriptable way to set Chrome as default as I'd love to do this as part of my onboarding :)

stevewood
Honored Contributor II
Honored Contributor II

@HelpDeskWarrior Take a VM, or a fresh machine, with just the OS, Chrome, and Composer added to it. Set Chrome to be the default browser either by using the System Preferences -> General pref pane, or by opening Chrome and setting Chrome as default. Once you have done that, open Composer and cancel out of the new package screen (Normal, New & Modified...) so that you are at the main composer window.

Open a new Finder window and navigate to ~/Library/Preferences/com.apple.LaunchServices/. Drag what should be the only file in that folder, com.apple.launchservices.secure.plist, to the left sidebar of the Composer window. Composer should then show you that folder structure added. From there, create a DMG file, upload to Casper Admin (or the JSS), and choose FEU & FUT under the options for the package.

Now that you have that DMG uploaded, create a new policy to deploy at login. I used a trigger of "Once per user" and scoped to machines enrolled in the last day. That way I hopefully do not pickup existing machines.

You can also look at using Outset to kick off the policy if you really wanted to.

@smithjw yeah, I was really hoping I would find a scripted solution, but I didn't. Apple must have changed something with either 10.12 or one of the later revs of 10.12 (perhaps 10.12.4?) that prevents the use of tools like duti or LaunchSetter, and makes tools like cdef and defaultbrowser kick up that pop-up. It's really annoying. I'd be fine if I could set this with a Configuration Profile, which to me would be the easiest and most logical method for doing this.

Hopefully I'm either completely missing something and someone else will comment with a solution that my Google-fu did not find, or Apple will fix this so we can set the default browser.

stevewood
Honored Contributor II
Honored Contributor II

@HelpDeskWarrior thinking over my previous response, I guess you do not necessarily have to use a VM or a new machine. Since the setting is a per user setting, you could just create a new user on the machine and log in under that user to create the necessary plist.

primalcurve
New Contributor III

I modified the script @stevewood mentioned above. It didn't work out of the box, but I figured out a method of getting the setting to stick and not leave a bunch of detritus in the plist. It works.

https://github.com/primalcurve/macsupportpub/blob/master/scripts/setGoogleChromeAsDefaultBrowser_Scr...

HelpDeskWarrior
New Contributor II

Thanks @primalcurve this script works perfectly for me.

Thanks for your efforts as well @stevewood unfortunately, your suggestions didn't work for me. Perhaps it was my execution.

lennyvaknine43
New Contributor

@primalcurve I tried using your modified script on 10.14 and found that while it did set chrome as the default browser, it messed up a lot of my application and dock icons to be the generic icons. I had to revert because of that ... any known solutions?

kcalderw
New Contributor
I tried using your modified script on 10.14 and found that while it did set chrome as the default browser, it messed up a lot of my application and dock icons to be the generic icons. I had to revert because of that ... any known solutions?

@lennyvaknine43 Did you ever come up with a fix for this? Or did @primalcurve fix his script? I just tried it on a test machine and it reset all my icons as well.

J_JohnstonAT
New Contributor II

So I have used @primalcurve script and does seem to do the trick for me, no issues with my dock. It's scoped in a policy which runs when the user logs on. However, even though the script does set the default browser to chrome when chrome is launched, it still prompts do you want to make chrome the default browser. Does anyone know of an addition to the script to suppress this pop-up message?

skentfive9
New Contributor II
However, even though the script does set the default browser to chrome when chrome is launched, it still prompts do you want to make chrome the default browser.

Have a look at this: https://cloud.google.com/docs/chrome-enterprise/policies/?policy=DefaultBrowserSettingEnabled

I use this to preinstall certain Chrome extensions in the browser. I too want to suppress that Google default popup.