Posted on 12-03-2013 07:58 AM
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.
Solved! Go to Solution.
Posted on 12-04-2013 03:00 AM
@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.
Posted on 12-04-2013 06:33 AM
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
Posted on 12-04-2013 03:00 AM
@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.
Posted on 12-04-2013 06:24 AM
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!
Posted on 12-04-2013 06:33 AM
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
Posted on 12-04-2013 06:56 AM
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!
Posted on 08-17-2015 12:27 AM
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
Posted on 08-22-2015 02:18 PM
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
Posted on 08-24-2015 10:57 AM
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!
Posted on 11-10-2015 05:47 PM
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';"
Posted on 03-24-2016 07:18 AM
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.
Posted on 06-14-2017 06:46 AM
@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"
Posted on 06-14-2017 06:58 AM
@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
Posted on 06-14-2017 07:20 AM
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
Posted on 06-14-2017 07:58 AM
@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 ?
Posted on 06-14-2017 08:07 AM
@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.
Posted on 06-14-2017 08:17 AM
@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
Posted on 06-14-2017 08:30 AM
@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.)
Posted on 06-14-2017 08:39 AM
@mark.sampers ok. dmg created.
When saving it into Casper Admin would i check the box INSTALL ON BOOT DRIVE AFTER IMAGING ?
Posted on 06-14-2017 08:48 AM
@mark.sampers ok. dmg created.
When saving it into Casper Admin would i check the box INSTALL ON BOOT DRIVE AFTER IMAGING ?
Posted on 06-14-2017 08:51 AM
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/
Posted on 06-14-2017 08:56 AM
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.
Posted on 06-14-2017 12:34 PM
@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 ?
Posted on 06-14-2017 12:34 PM
@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 ?
Posted on 06-14-2017 01:49 PM
@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.
Posted on 06-15-2017 06:34 AM
@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
Posted on 06-15-2017 06:46 AM
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
Posted on 07-20-2017 04:57 AM
@greatkemo hi, the script worked, but do you have any idea how can I add some bookmarks to the gogle chrome using a script?
Posted on 07-20-2017 06:03 AM
@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
Posted on 08-15-2017 08:06 PM
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'
Posted on 08-16-2017 05:29 AM
@HelpDeskWarrior I just spent 4 days trying to set Chrome as default. I tried everything from:
duti
- received same "error -54" every timedefaultbrowser
- works but pops up the "Are you sure you want to change from Safar" dialogcdef
- same as defaultbrowser
, it works but pops the dialogLaunchSetter
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.
Posted on 08-16-2017 09:08 PM
@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?
Posted on 08-16-2017 11:28 PM
@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 :)
Posted on 08-17-2017 05:10 AM
@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.
Posted on 08-17-2017 06:52 AM
@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.
Posted on 08-22-2017 02:03 PM
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.
Posted on 08-22-2017 07:05 PM
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.
Posted on 10-10-2018 12:01 PM
@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?
Posted on 11-14-2019 08:10 AM
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.
Posted on 03-09-2020 05:32 AM
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?
Posted on 06-09-2020 04:00 PM
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.