How to Launch an AIR Application from the Command Line

These days, desktop applications are usually launched either from the Windows Shell, Mac OS Finder, KDE Desktop, etc. Less well-known is that these operating systems all also allow applications to be launched directly from the command line, terminal, DOS prompt, etc. When launched from the command line, applications can also receive command line arguments.

Consistent with our goal of making AIR-based applications as much like regular desktop applications as possible, this also works for AIR-based applications. In AIR, those command line arguments are received via the InvokeEvent dispatched from NativeApplication. This can prove useful in a variety of situations, especially when writing scripts for testing or other automated work.

On Windows and Linux, invoking AIR-based applications at the command line is straightforward. On Windows, inside the application’s install directory you’ll find an executable with the application’s name; that’s the thing to run from the command line. On Linux, the executable is inside the “bin” subdirectory.

On Mac OS things are slightly trickier. In Finder, applications appear to be a single file, but they’re really a folder with with an extension of “.app” and a particular interior folder structure. To launch them from the command line with arguments, you have to dig into this structure and find the executable. For example, to launch an application named HelloWorld you’d run:


You can also run an application on Mac OS via the “open” command, but open doesn’t support passing any command line arguments to the application.

One final note: You can also pass arguments to your application when debugging with adl. However, since adl takes its own arguments as well, you need to separate the adl arguments from the arguments intended for the application with the double-dash argument, like so:

adl HelloWorld-app.xml — a b c

In this example, the application will receive an InvokeEvent with arguments a, b, and c.

4 Responses to How to Launch an AIR Application from the Command Line

  1. HiI’m not sure I understand what you say here about launching an AIR app from the command line (on OSX).I launch my own AIR apps on OSX using the “open” command, and I pass it any argument I -a MyApp arg1 arg2;I use this to launch my AIR apps from -a ADM $1;More info about it here: I miss something ?

  2. Oliver Goldman says:

    My experience is that arguments can only be passed via the “open” command if they refer to real files. For example, this returns an error:> open -a MyApp /nosuchfile.txtThe file /nosuchfile.txt does not existBut this does work:> open -a MyApp /thisfileexists.txtConsistent with this behavior, applications receive an “open” event from Mac OS when launched in this way, and open events are intended to refer to files.So I think your approach will work under certain circumstances, but the approach described in the post will work in more cases.

  3. madhu says:

    Is there any way to launch AIR application from another AIR application?[See this post for my reply. —Oliver]

  4. LT says:

    Thanks for writing on this subject. Is it possible for an Air app, launched via command line, to return output to the command line?[No; there’s no API for that. If you’re interested in writing command line applications with ActionScript, check out avmshell command that’s part of Tamarin. —Oliver]