user635064
user635064

Reputation: 6247

Path to application without opening it

I want to get a path to any application, and this is what I do:

set i to path to application id "com.adobe.Photoshop"

This gets me the path but also opens Photoshop. How can I make it so it doesn't open Photoshop?

Upvotes: 1

Views: 2271

Answers (1)

regulus6633
regulus6633

Reputation: 19040

Here's one way... use lsregister which uses Launch Services. This gives a list of all matching apps.

set lsRegisterPath to "/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister"
set appBundleID to "com.adobe.Photoshop"

-- get the path to all apps with the bundle id
set theAppPaths to paragraphs of (do shell script lsRegisterPath & " -dump | grep --before-context=2 \"" & appBundleID & "\" | grep --only-matching \"/.*\\.app\"")

Upvotes: 1

Related Questions