9/4/2010 10:29:45 PM
Title:
Launch an Exe
Can I launch an exe file from inside an air applcation?
If yes please help me with a code.
Thanks.
9/4/2010 11:50:57 PM
there is no direct way to launch exe from adobe air application . But you can use command proxy. Command proxy can interact with OS and AIR can interact with Command proxy . See this article for more details
http://www.mikechambers.com/blog/2008/01/17/commandproxy-net-air-integration-proof-of-concept/
download commandproxy from this link
http://code.google.com/p/commandproxy/
9/5/2010 11:45:09 PM
Hi John
I am not sure that this is exactly you need or not but may be help you....
http://www.adobe.com/devnet/air/flex/quickstart/interacting_with_native_process.html
Regards,
Virat Patel
9/7/2010 2:28:28 AM
Simply run below code in FlashBuilder 4 and you are doen with it.This will launch ping utility.Just replace "C:\\WINDOWS\\system32\\ipconfig.exe" with the path of your desired installed program such as MS World,Excel,etc.
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
private var processBuffer;
private var nativeProcess;
private function executeCommand():void {
// #1 check if u can exec native processes
if (!NativeProcess.isSupported) {
Alert.show("NativeProcess.is NOT Supported");
return;
}
// # get a NativeProcessStartupInfo object ready
var npInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
//var file:File = new File("C:\\WINDOWS\\system32\\ipconfig.exe")
var file:File = File.applicationDirectory;
file = file.resolvePath('C:/Program Files/Microsoft Office/Office12/WINWORD.EXE');
try {
npInfo.executable = file;
} catch (e:Error) {
Alert.show(e.message);
return;
}
// get a output buffer
processBuffer = new ByteArray();
// create a NativeProcess object, add listeners and execute it (i.e start it)
nativeProcess = new NativeProcess();
nativeProcess.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA,onStandardOutputData);
nativeProcess.addEventListener(NativeProcessExitEvent.EXIT,onStandardOutputExit);
nativeProcess.start(npInfo);
}
// handle output data
private function onStandardOutputData(e:ProgressEvent):void {
nativeProcess.standardOutput.readBytes(this.processBuffer,this.processBuffer.length);
}
private function onStandardOutputExit(e:Event):void {
var output:String = new String(processBuffer);
trace (output);
}
]]>
</mx:Script>
<mx:Button id="btn" label="click" click="executeCommand();"/>
</mx:WindowedApplication>