How do I compile the following script without actually activating the application during the compilation?

tell application "/Applications/VLC.app" to activate

If I do e.g. this, it will not only create a launcher bundle, but also activate VLC.app during compilation:

osacompile  -o foo.app -e 'tell application "/Applications/VLC.app" to activate'

This launches VLC immediately, even if you don't touch foo.app.

I played around with the Info.plist in VLC.app and I found that the offending flag is this one:


If the target app bundle specifies that, it will launch on compilation. I can only assume osacompile does some kind of inspection on the bundle, sees that flag, then somehow has to activate the app to inspect its applescript support?

VLC is just a place holder here, I'm trying to programmatically create launchers for arbitrary applications. My current work-around is do shell script "open \"/Applications/VLC.app\"". It works for activating (the run hook), but not for other hooks, e.g.

on open names
  tell application ... to open names
end open

That also opens the target app on compilation if it declares support for apple script.

My question is: how do I avoid that, and just create a pure launcher script without osacompile actually launching the app?

1 Answer 1


You are correct that the application is launched to get its scripting terminology. Your best bet would probably be to create and test the individual scripts, then escape each script as a string and put the string literals into a list. From there you can use run script or osascript with the desired script string so that the script is not compiled until it is used with the command, for example:

set scriptText to "
on run args
    tell application \"VLC\"
        if args is not in {missing value, {}, me} then open first item of args -- whatever
    end tell
end run
run script scriptText -- with parameters {list of paths}
-- or --
do shell script "osascript -e " & quoted form of scriptText -- & space & quoted form of "/path/to/file"

To use open with arguments, you just need to use the --args option:

do shell script "open '/Applications/VLC.app' --args " & quoted form of "/path/to/file"

For the shell scripts, additional arguments are space separated quoted paths. For larger argument lists, you can also escape the individual paths and join them into a single string with separating spaces.

  • Thank you for this answer. I'm holding out for a solution which doesn't involve wrapping the string like this, although I have a feeling it just isn't possible.
    – hraban
    Commented Jul 7 at 18:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .