views:

34

answers:

2

Here's the issue:

I have a list of App names that I want to launch. They do not include a path (e.g. {"VLC","Microsoft Word"}. I have two different copies of VLC in different directories. I would like Launch Services to ONLY open the one from /Applications/ and not EVER launch from /Applications/AnotherDirectory

I want to get the path of these, and test to see what Launch Services wants to launch (via bash with "open" or applescript via "tell _ to launch" or [NSWorkspace launch...])

The only way that I have come up with to test the path of a file about to be launched by launch services is:

Applescript:

tell application "Finder" to return the (posix path of (path to application "VLC" as alias))

That works fine, but launches the app (which I don't want at all).

Suggestions?

A: 

You can use LSFindApplicationForInfo(), which "Locates an application with a specified creator signature, bundle ID, filename, or any combination of these characteristics."

Graham Lee
thanks, I'll look into that.
Andrew J. Freyer
A: 

If you have the bundle ID of an application, you can get the path to the application without launching it using the following script:

tell application "Finder"
    URL of application file id "org.videolan.vlc"
end tell

This produces the following output in the Event Log:

tell application "Finder"
    get URL of application file id "org.videolan.vlc"
        "file://localhost/Applications/VLC.app/"
end tell
sakra