0

Unable to open exe file using Adobe Animate and XML configuration

I'm trying to open an exe file from another exe file using Adobe Animate and XML configuration. However, the code seems to be correct, but the exe file is not opening. Here's the code I'm using:

// open exe from exe

import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.filesystem.File;
import flash.desktop.NativeProcess;
import flash.desktop.NativeProcessStartupInfo;

stop();

var config:XML;
var configLoader:URLLoader = new URLLoader();
configLoader.addEventListener(Event.COMPLETE, onConfigLoaded);
configLoader.load(new URLRequest("config.xml"));

function onConfigLoaded(event:Event):void {
  config = XML(event.target.data);
}

btn1.addEventListener(MouseEvent.CLICK, openExe);

function openExe(event:MouseEvent):void {
  trace("Button clicked");
  var exeName:String = event.target.name;
  
  // Find the corresponding executable path in the XML configuration
  var exePath:String = config.exes.exe.(@name == exeName).path;
  
  // Create a File object with the executable path
  var file:File = new File(exePath);
  
  // Prepare the NativeProcessStartupInfo with the executable file
  var processInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
  processInfo.executable = file;
  
  // Start the native process
  var process:NativeProcess = new NativeProcess();
  process.start(processInfo);
}

Steps to reproduce:

Ensure that the "config.xml" file contains the correct paths for the exe files. Click on the "btn1" button to trigger the openExe function. Expected behavior:

The code should open the specified exe file when the button is clicked.

Actual behavior:

The exe file does not open, and there are no error messages or indications of any issue.

Additional information:

I have verified that the paths in the "config.xml" file are correct. I'm using Adobe Animate with the latest version of the AIR SDK (50.1.1.2). I have tested the code on Windows 10 and Windows 11 x64. I have checked the security settings and file permissions for the exe files. Note:

I would appreciate any insights or suggestions on what might be causing the issue and how to resolve it. Thank you in advance for your help!

  • What happens if, after `trace("Button clicked");`, you add a next line like: `if(NativeProcess.isSupported){ trace("OK ::: NativeProcess is ready to load EXE file"); } else{ btn1.alpha = 0.3; trace("Error ::: NativeProcess is not available"); return; }` – VC.One Jun 01 '23 at 19:57
  • If the button fades out a little bit then NativeProcess is not available, maybe because you are testing in the IDE? If running as an installed app it should work, I think an AIR file can also run a NativeProcess (without installing AS3 code as a Windows app)... – VC.One Jun 01 '23 at 20:05

0 Answers0