Adobe AIR to execute program

34,637

Solution 1

There's no direct way of doing it. Try CommandProxy.

Read the blog post very carefully. You really need to create two different projects: a native OS executable and an AIR app. The native executable fires up your AIR application. The AIR application in turn requests for the executable to process OS-level requests.

Download the source from Google Code and create two projects -- a Visual Studio/Mono for the sample C# exe and another -- for the AIR application. Here is a link that describes how to set up the former.

In your AIR app's main MXML file, you need to do the following:

  • Create a CommandProxy object, add a few event listeners, for connection detection, and Command response and error.

  • Connect to the native exe via a connect call

  • In the event handler for connect, create a new Command e.g. ScreenshotCommand and execute it (via CommandProxy.execute method)

... and that's it!

Hope this helps.

Solution 2

With AIR 2.0 you now can:

if(NativeProcess.isSupported)
{
    var file:File = File.desktopDirectory;
    file = file.resolvePath("StyleLookupold.exe");

    var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
    nativeProcessStartupInfo.executable = file;
    var process:NativeProcess = new NativeProcess();

    process.start(nativeProcessStartupInfo);

}

You also need to add this to your descriptor file.

<supportedProfiles>extendedDesktop</supportedProfiles> 

Solution 3

The answer comes in two parts. One, if you really MUST run a .exe file, the only way to go is to use a command proxy. Personally, using one in .Net/Mono is a bit overblown. I don't know Mono, but asking your users to install .Net and AIR would scare just about all of them away. Plus, if I was going to ask users to install Mono, why not just write the UI in Mono and be done with it...?

You could write a simple command proxy in Ruby which really would be cross-platform and low hassle in about 5 minutes (I just did it, if you want the code comment me here and I'll post it). If you want control of the process after it's launched, it's a more serious endeavor. For distribution, etc., I believe that Ruby would be easier.

On the other hand, check this idea out. Jeff suggests using a URL request from AIR. Basically, if your browser would interpret it correctly, you're ready to go. The code looks like this

var request : URLRequest = new URLRequest('C:\\playlists\\test.m3u');

I think that, with a bit of creativity (with Mime types, particularly), this second solution might even work for Winamp (e.g.., a playlist or something).

Good luck and thank you for the question, which is probably a dupe but Google only found this one so you've won :)

Solution 4

I think FluorineFx does what you want: http://aperture.fluorinefx.com/?p=5

Solution 5

See this blog post: Run an exe file from AIR

Short summary:

"If you really need to run external exe files, and there is no other way of solving your problem, then you will make sure that the user runs that another software before launching the AIR application."

Share:
34,637
Robocop
Author by

Robocop

Updated on October 07, 2020

Comments

  • Robocop
    Robocop over 3 years

    I would like to press a button from an Adobe AIR application and execute some installed program. For example, I would have a button named "Start Winamp". When this is pressed it should start Winamp.exe directly...I don't want some command line thing executed, I only want an exe to start. Or...is it the same thing ? Please, let me know if this is possible.

    Thank you.