Question

Working code:

When running adl application.xml on an AIR project in development, my Native Process works fine using this code:

var os = air.Capabilities.os.toLowerCase();
if(os.indexOf('win') >= 0)
    var exe = 'win/myExecutable.exe';
else if(os.indexOf('mac') >= 0)
    var exe = 'mac/myExecutable';
else if(os.indexOf('linux') >= 0)
    var exe = 'nix/myExecutable';

var file = air.File.applicationDirectory.resolvePath('res/somepath/' + exe);

var args = new air.Vector["<String>"]();
args.push('anArgument');
args.push('another');

var info = new air.NativeProcessStartupInfo();
info.executable = file;
info.arguments = args;

var process = new air.NativeProcess();
process.start(info);
process.closeInput();

With this directive in application.xml:

<supportedProfiles>extendedDesktop desktop</supportedProfiles>

Problem:

After compiling my app into an .air file, the executable fails to launch.

Debugging:

Upon adding an empty file named debug to C:\Program Files (x86)\My App\My App\META-INF\AIR, and adding a file called mm.cfg to %USERPROFILE% with the following in:

ErrorReportingEnable=1
MaxWarnings=1000
SuppressDebuggerExceptionDialogs=1
TraceOutputFileEnable=1

The following output is written to %USERPROFILE%\AppData\Roaming\Macromedia\Flash Player\Logs\flashlog.txt:

Error: Error #3219: The NativeProcess could not be started. 'Not supported in current profile.'

How can I fix this?

Was it helpful?

Solution

Pre-requisites:

The Packaging a desktop native installer article on Adobe's website states:

Applications installed with a native application installer are known as extended desktop profile applications.

It goes on:

When you create a native installer to distribute an AIR application, the application gains these capabilities:

  • It can launch and interact with native processes, using the NativeProcess class.

Compiling:

Essentially, your .air file must be compiled as a native installer (i.e. a .exe, .dmg, .deb or .rpm file) in order for you to use native processes (as well as a couple of other things).

To do so, install the AIR SDK (information on how to do so can be found at my other answer, here), and run this command from a Command Prompt:

adt -package -target native "Output file.exe" "Input file.air"

Your resulting installer (with built-in AIR runtime) will now work perfectly with processes!

A final word on cross-compatibility:

You must use ADT on the same operating system as that of the native installer file you want to generate. So, to create an EXE file for Windows, run ADT on Windows. To create a DMG file for Mac OS, run ADT on Mac OS. To create a DEB or RPG1 file for Linux, run ADT from the AIR 2.6 SDK on Linux.

1. This is a typo on Adobe's part and should read RPM, not RPG.

If you want a file to be executable in your installed application, make sure that it's executable on the filesystem when you package your application. (On Mac and Linux, you can use chmod to set the executable flag, if needed.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top