pass parameter in flex NativeProcess

I want to pass two parameter to nativeProcess.

While i am running exe file using windows command with parameter, it is working. Command for window is "abc.exe a.txt b.txt"

How can I pass two parameters to the exe in that format using flex nativeProcess?

This is what I have so far:

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
                       xmlns:s="library://ns.adobe.com/flex/spark" 
                       xmlns:mx="library://ns.adobe.com/flex/mx" applicationComplete="windowedapplication1_applicationCompleteHandler(event)">
    <fx:Script>
        <![CDATA[
            import mx.events.FlexEvent;

            private var process:NativeProcess;
            protected function windowedapplication1_applicationCompleteHandler(event:FlexEvent):void
            {
                if (NativeProcess.isSupported)
                {
                    callExe();
                }
                else
                {
                    textReceived.text = "NativeProcess not supported.";
                }
            }

            public function callExe():void
            {
                var a_FilePath:String = File.applicationStorageDirectory.resolvePath("dist/a.txt").nativePath;
                var b_FilePath:File = File.applicationStorageDirectory.resolvePath("dist/b.txt").nativePath;

                if (Capabilities.os.toLowerCase().indexOf("win") > -1)
                {
                    var file:File = File.applicationStorageDirectory.resolvePath("dist/abc.exe");
                }

                var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();

// i put the line below and it works in my case

nativeProcessStartupInfo.workingDirectory = File.applicationStorageDirectory.resolvePath();

nativeProcessStartupInfo.executable = file;

                var args:Vector.<String> = new Vector.<String>();
                args.push(a_FilePath);
                args.push(b_FilePath);

                nativeProcessStartupInfo.arguments = args;

                process = new NativeProcess();
                process.start(nativeProcessStartupInfo);
                process.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, onOutputData);
                process.addEventListener(ProgressEvent.STANDARD_INPUT_PROGRESS, inputProgressListener);
                process.addEventListener(ProgressEvent.PROGRESS, progressEvent);
                process.addEventListener(ProgressEvent.STANDARD_ERROR_DATA, errorData);
            }

            public function inputProgressListener(event:ProgressEvent):void
            {
                textReceived.text += "Input Progress Event";
            }
            public function onOutputData(event:ProgressEvent):void
            {
                textReceived.text += "Output Event";
            }
            public function progressEvent(event:ProgressEvent):void
            {
                textReceived.text += "Progress Event";  
            }
            public function errorData(event:ProgressEvent):void
            {
                textReceived.text += "Error Event";
            }
        ]]>
    </fx:Script>
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>

    <mx:TextInput id="textReceived" width="352" height="200"/>

</s:WindowedApplication>

Answers


I solved my puzzle by adding the line below in bold:

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
                       xmlns:s="library://ns.adobe.com/flex/spark" 
                       xmlns:mx="library://ns.adobe.com/flex/mx" applicationComplete="windowedapplication1_applicationCompleteHandler(event)">
    <fx:Script>
        <![CDATA[
            import mx.events.FlexEvent;

            private var process:NativeProcess;
            protected function windowedapplication1_applicationCompleteHandler(event:FlexEvent):void
            {
                if (NativeProcess.isSupported)
                {
                    callExe();
                }
                else
                {
                    textReceived.text = "NativeProcess not supported.";
                }
            }

            public function callExe():void
            {
                var a_FilePath:String = File.applicationStorageDirectory.resolvePath("dist/a.txt").nativePath;
                var b_FilePath:File = File.applicationStorageDirectory.resolvePath("dist/b.txt").nativePath;

                if (Capabilities.os.toLowerCase().indexOf("win") > -1)
                {
                    var file:File = File.applicationStorageDirectory.resolvePath("dist/abc.exe");
                }

                var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();

// i put the line below and it works in my case

nativeProcessStartupInfo.workingDirectory = File.applicationStorageDirectory.resolvePath();

nativeProcessStartupInfo.executable = file;

                var args:Vector.<String> = new Vector.<String>();
                args.push(a_FilePath);
                args.push(b_FilePath);

                nativeProcessStartupInfo.arguments = args;

                process = new NativeProcess();
                process.start(nativeProcessStartupInfo);
                process.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, onOutputData);
                process.addEventListener(ProgressEvent.STANDARD_INPUT_PROGRESS, inputProgressListener);
                process.addEventListener(ProgressEvent.PROGRESS, progressEvent);
                process.addEventListener(ProgressEvent.STANDARD_ERROR_DATA, errorData);
            }

            public function inputProgressListener(event:ProgressEvent):void
            {
                textReceived.text += "Input Progress Event";
            }
            public function onOutputData(event:ProgressEvent):void
            {
                textReceived.text += "Output Event";
            }
            public function progressEvent(event:ProgressEvent):void
            {
                textReceived.text += "Progress Event";  
            }
            public function errorData(event:ProgressEvent):void
            {
                textReceived.text += "Error Event";
            }
        ]]>
    </fx:Script>
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>

    <mx:TextInput id="textReceived" width="352" height="200"/>

</s:WindowedApplication> 

Need Your Help

UITableViewCell contentLayer backgroundColor won't cover accessory's background

iphone ios uitableview background-color

I'm writing a small application to teach myself new design and information retrieval tricks. I'm using the following line to set the background of my UITableViewCell subclass:

ASP - New instance of SQL database per user?

c# asp.net sql entity-framework

I have been struggling with this for some time, and can't seem to find any info.