Search code examples
actionscript-3apache-flexair

AIR Native process Error


I try to launch a programm with NativeProcess on Mac.

pathEV="/Applications/MyFolder/MyAppOSX.app"
var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
var fileEV:File = new File();
fileEV=fileEV.resolvePath(pathEV);
nativeProcessStartupInfo.executable = fileEV;
var process:NativeProcess = new NativeProcess();
process.start(nativeProcessStartupInfo); 

But this error appear: Error #3214: NativeProcessStartupInfo.executable does not specify a valid executable file

Can you help me to solve that? Thanks


Solution

  • Haven't tested it yet, but I assume you'd need to run open with the path to your application as a parameter, like this:

    pathEV:String="/Applications/MyFolder/MyAppOSX.app"
    var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
    var fileEV:File = new File();
    fileEV=fileEV.resolvePath( '/usr/bin/open' );
    nativeProcessStartupInfo.arguments = Vector.<String>([pathEV]);
    nativeProcessStartupInfo.executable = fileEV;
    var process:NativeProcess = new NativeProcess();
    process.start(nativeProcessStartupInfo); 
    

    And yes, this definitely needs extendedDesktop rights

    FYI: The Vector shizzle is correct, I use it to convert the array to Vector, not as a constructor function

    Here's an explanation how to launch .app files from the terminal