Setting default open with app?

quedayone
Contributor

Best practice to set the default open with application? I need to set all PDF's to open with Acrobat Pro. I don't see any MCX template for it. I know the preference is stored in com.apple.launchservices.plist.

Thanks in advance for any thoughts or help.

Wi11

1 ACCEPTED SOLUTION

talkingmoose
Moderator
Moderator

I use the following in Managed Preferences (using underscores to show indentation):

Display Name: Default applications
Description: Sets preferred applications.
Apply Setting To: User Level At Every Login
Domain: ~/Library/Preferences/com.apple.LaunchServices
Key: LSHandlers
Value:

<array>
<dict>
_____
<key>LSHandlerContentType</key>
____<string>com.adobe.pdf</string>
____<key>LSHandlerRoleAll</key>
____<string>com.adobe.acrobat.pro</string>
</dict>
<dict>
____<key>LSHandlerContentTag</key>
____<string>pdf</string>
____<key>LSHandlerContentTagClass</key>
____<string>public.filename-extension</string>
____<key>LSHandlerRoleAll</key>
____<string>com.adobe.acrobat.pro</string>
_</dict>
</array>

This includes two examples. The first key is LSHandlerContentType, which assigns Acrobat Pro to open PDF files based on file type. The second key is LSHandlerContentTag, which assigns Acrobat Pro to open PDF files based on file extension. Use either or both. Shouldn't make a difference.

View solution in original post

20 REPLIES 20

talkingmoose
Moderator
Moderator

I use the following in Managed Preferences (using underscores to show indentation):

Display Name: Default applications
Description: Sets preferred applications.
Apply Setting To: User Level At Every Login
Domain: ~/Library/Preferences/com.apple.LaunchServices
Key: LSHandlers
Value:

<array>
<dict>
_____
<key>LSHandlerContentType</key>
____<string>com.adobe.pdf</string>
____<key>LSHandlerRoleAll</key>
____<string>com.adobe.acrobat.pro</string>
</dict>
<dict>
____<key>LSHandlerContentTag</key>
____<string>pdf</string>
____<key>LSHandlerContentTagClass</key>
____<string>public.filename-extension</string>
____<key>LSHandlerRoleAll</key>
____<string>com.adobe.acrobat.pro</string>
_</dict>
</array>

This includes two examples. The first key is LSHandlerContentType, which assigns Acrobat Pro to open PDF files based on file type. The second key is LSHandlerContentTag, which assigns Acrobat Pro to open PDF files based on file extension. Use either or both. Shouldn't make a difference.

quedayone
Contributor

Talking moose, it was great meeting you at the JUNC, and thank you for the response! I also created one to set email to outlook.
Wi11

tlarkin
Honored Contributor

You can also check out duti, which will allow you to associate certain file types with certain applications

http://duti.sourceforge.net/

talkingmoose
Moderator
Moderator
Talking moose, it was great meeting you at the JUNC, and thank you for the response! I also created one to set email to outlook.

Enjoyed meeting you as well and finally putting a face behind the Twitter account! Setting Outlook to be the default? Now, I don't even do that. ;-)

quedayone
Contributor

We just rolled out a SharePoint site and Safari was sending email links to mail. It was confusing our users.

Huber
New Contributor

Goal: To Make MS Outlook the default application for Mail, Contacts, and Calendars at imaging or first login. Seeing problems with changing the launchservices plist. I've created a script that adds the above components (all com.microsoft.outlook Handlers) to com.apple.launchservices.plist so that all pertinent file types roll to MS Outlook, making it the default. This script runs and successfully adds these pieces to the plist. Upon testing a generic .ics file, iCalendar continues to open. Mail shows that Outlook is the default app, but I've waited on changing this preference in Outlook. If this change is made, then all works well. Is there another plist that is getting changed? Or am I missing something with ownership/permissions modifications? Thanks...curious if anyone has a fix here.

tkimpton
Valued Contributor II

+1 for duti :)

esantiago
New Contributor

@Huber Did you ever get it working.

Default everything to MS Outlook on Imaging/ FIrst login.??

Can I see the script you used?

dstranathan
Valued Contributor II

@talkingmoose Raising the dead here - sorry. Do you know if this config can be applied at the computer level rather than the ~/user level?

talkingmoose
Moderator
Moderator

I wouldn’t try it anymore.

The reason it worked back then was because Jamf was using MCX Managed Preferences, which supported the Often option. It literally edited the current user’s plist file.

Today, if you try to do this with a configuration profile, these settings may work but anything you don’t explicitly include won’t work.

Looking to set Acrobat or something else? I’ve found a few useful scripts on here for managing those settings.

dstranathan
Valued Contributor II

Thanks William!

I am trying to set Fiji.app (a scientific app based on ImageJ) to open all .dv files (currently QuickTIme tries...and fails...and makes scientist sad and frustrated).

Our .dv files are not movie/video files per-se, they are 3-D z-axis "slices" of cells that are in the form of .dv and only Fiji.ap can open them.

I have been wrestling with Launch Services and haven't found a global way to set the file extensions .dv to open with Fiji yet (dev ID is org.fiji). And it looks like the duti utility is long in the tooth at thins point.

I already tried writing a KB article to teach scientists how to manually set the Fiji.app on a per-user basis (Get info > "Always Open With...") but they are still a little confused. I want to end this problem and blast-out a script/profile to set the app/file relationship and forget it!

tjhall
Contributor III

@dstranathan Have you had a look at "SwiftDefaultsApps" (https://github.com/Lord-Kamina/SwiftDefaultApps).
We pushed out the CLI and then set the default app via a command line policy.

dstranathan
Valued Contributor II

Nice - Ill check it out. A Pref Pane might be handy too. I ended up running a Python script (thanks to @pbowden).

jbanks
New Contributor III

I'm looking to do the same. I've got 10 laptops that are distributed as loaners while machines are in for repair. The helpdesk is unhappy with having to set Acrobat Reader as the default app for all PDFs (I'm not sure why they can't just use Preview, but that's not my battle).

What has everyone used that works?

tjhall
Contributor III

@jbanks I'm happy with "SwiftDefaultsApps". We distributed the cli only (didn't want to add the system prefs) and then set the defautl app via policy or script. Advantage is that once it's there it's easy to do any additional changes.

https://github.com/Lord-Kamina/SwiftDefaultApps/releases

rqomsiya
Contributor III

@tjhall

Do you have any documentation or example script you use to set default apps? I don't see example commands on Github.

Thanks!

john-hsu
New Contributor III

@rqomsiya

I was just working with the SwiftDefaultApps command line a little bit ago, and this is what I found works for me. I'm looking to set the .pdf extension to open in Acrobat Reader instead of Acrobat Pro for our Mac Labs (since Adobe Pro folks would have to sign in). This command line seems to be working for me:

./swda setHandler --application /Applications/Adobe Acrobat Reader DC.app --UTI com.adobe.pdf

I haven't implemented a test in Jamf yet. Just thought I would pass along what I found what seems to be working for me. You can have the command line list the defaults for all extensions by typing this command:

./swda getUTIs

I found it helpful to install the preference pane on my system to help me sort out the terminology. I hope this helps you a little bit.

tjhall
Contributor III

Took me a while to figure this out but changing the filetype needs to be based on the correct attribute information.
I run this command first to determine the appropriate file attribute : mdls /path/to/file
This gives you the correct interpreter for the filetype you are trying to set.
Example for .csv: kMDItemContentType "public.comma-separated-values-text"

You then issue the command to swiftdefaultsapps cli (rolled out to /bin folder in this case) to set Excel to open csv files: /usr/local/bin/swda - setHandler --app /Applications/Microsoft Excel.app/ --UTI public.comma-separated-values-text

You can do a check on the current set apps by running this (swda cli in /bin): /usr/local/bin/swda - getUTIs

The variables for SwiftDefautlApps are:
- getHandler Returns the default application registered for the URI Scheme or <subtype> you specify.
- getApps Returns a list of all registered applications.
- getSchemes Returns a list of all known URI schemes, accompanied by their default handler.
- getUTIs Returns a list of all known UTIs, and their default handler.
- setHandler Sets <application> as the default handler for a given <type>/<subtype> combination.
- help Prints this help information
- version Prints the current version of this app

Hope this helps
T

DavidN
Contributor

The app SWDA is working in command line " /usr/local/bin/SwiftDefaultApps/swda setHandler --app /Applications/IBM Notes.app --mail", but I cannot get it working with a launchAgent. Has anyone got this working?