• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Launching external exe in AIR

Explorer ,
Aug 02, 2011 Aug 02, 2011

Copy link to clipboard

Copied

Need to launch an external program through Flash AIR. Tried reading up but are unable to get it working. Think there is something else I need to perform before launching my external file (exe). It is a exercise that is like a game.

var myApp:File = File.applicationDirectory.resolvePath("Hazards.exe");
var myAppProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
var myAppProcess = new NativeProcess();

myAppProcessStartupInfo.executable = myApp;
myAppProcess.start(myAppProcessStartupInfo);

Throws this error when I run it inside Flash. And nothing after launching. In some debug I see that NativeProcess.isSupported = false;

Error: Error #3219: The NativeProcess could not be started. 'Not supported in current profile.'
at Error$/throwError()
at flash.desktop::NativeProcess/start()
at launching_fla::MainTimeline/launchFile()[launching_fla.MainTimeline::frame1:27]

How do I get a external file to launch with AIR?

THANKS

TOPICS
ActionScript

Views

10.3K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 02, 2011 Aug 02, 2011

Copy link to clipboard

Copied

assuming you're importing those classes (and it appears you are), you should be checking if the nativeprocess is supported on the host computer by using the static isSupported property of the NativeProcess:

if(NativeProcess.isSupported){

var myAppProcess:NativeProcess=new NativeProcess();

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 02, 2011 Aug 02, 2011

Copy link to clipboard

Copied

Yes I've done the check and it comes back false... meaning not supported. I read in the documention that you have to assign a profile? Here is the link...

http://help.adobe.com/en_US/air/build/WS144092a96ffef7cc16ddeea2126bb46b82f-8000.html

Not sure how this would help. From what I have read for AIR this is what I should be using. If I had an example that worked then I could adapt but I have not found one over the web yet at least. Even tried the File.openWithDefaultApplication and that wouldn't even open a text document or word doc file.

Any suggestions?

THANKS for getting back to me. This is as usual a time sensitive manner. LOL

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 02, 2011 Aug 02, 2011

Copy link to clipboard

Copied

You need to have <supportedProfiles>extendedDesktop</supportedProfiles> in the app xml for NativeProcess class to work.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 02, 2011 Aug 02, 2011

Copy link to clipboard

Copied

Thanks, I have both desktop and extendedDesktop checked off in the AIR panel. When I just use the extendedDesktop I get an error. Still won't launch an external exe file on the root of my course.

PLEASE... any suggestions greatly appreciated. They are all over me about this.

Thanks

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 02, 2011 Aug 02, 2011

Copy link to clipboard

Copied

What is the error? Did you check the xml?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 02, 2011 Aug 02, 2011

Copy link to clipboard

Copied

LATEST

Believe I have found the problem. After reading a few more doc files it was mentioned to have a installer package. I thought AIR was the installer package. No I was wrong there. The NativeProcess.isSupported was always returning false. Not till after checking the box for the Windows Installer was I able to get the NativeProcess set to true; Below is the final code...

import flash.filesystem.*;
import flash.desktop.NativeProcessStartupInfo;
import flash.desktop.NativeProcess;

var myApp:File = File.applicationDirectory.resolvePath("Hazards.exe");
var myAppProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
var myAppProcess = new NativeProcess();

myAppProcessStartupInfo.executable = myApp;
myAppProcess.start(myAppProcessStartupInfo);

Screen Shot from AIR:

AIR_Setting.JPG

Thanks to everyone for the support and help. Hopefully someone will be able to use this in their AIR projects as well.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines