I want to create a script for opening an app in nonstandard location quickly. With AppleScript, the app can be started with:

tell application [app path] to run

I want to do the same using javascript cause I am more familiar. But Application([app path]).run() does not work. In fact, the Application object does not seem to have any attributes.

2 Answers 2


Finally found an answer myself from JXA-Cookbook:

$.NSWorkspace.sharedWorkspace.launchApplication('[app path]')
  • Could you please accept this answer as correct. This will help others know an answer was found Commented Jan 1, 2022 at 19:59

The following works when executed in the Script Editor application.

var app = Application.currentApplication()
app.includeStandardAdditions = true
app.doShellScript('open -a [app path]')

Note: This answer was derived from the following question and accepted answer: What's the equivalent of "do shell script" with javascript automations? (Yosemite)

  • Thanks. It works after saving as an application bundle. But using shell for launching is a bit odd...
    – cdowen
    Commented Dec 23, 2021 at 14:09
  • Your question does not include where you intended to use the javascript. So I did limited testing. The answer may appear odd, but at least the answer is simple to implement. Commented Dec 23, 2021 at 14:31
  • Actually, using do shell script/doShellScript from AppleScript/JavaScript to execute a shell script is no more odd than using osascript from a shell script to execute AppleScript/JavaScript. Basically, you use which ever language or shell that works best for your needs. Commented Dec 23, 2021 at 15:08
  • In fact, I am trying to bundle the script so that it appears in the launchpad. Finally I find the solution in the jxa-cookbook. Thank you anyway.
    – cdowen
    Commented Dec 23, 2021 at 17:34

You must log in to answer this question.

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