How to execute CMD commands in flex using actionscript?

I would like to programmatically execute the CMD command from my flex application. Sort of

> mediaplayer.exe "mySong.mp3"

I also tried using fscommand, but was not successful. While googling, I found out that AIR does not support it. I would like to know if there is another alternative for executing commands. Thank...

+3
source share
2 answers

You need to use NativeProcessone that is only available in AIR 2.0 +

This should do the trick:

if(NativeProcess.isSupported)
{
    var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();

    var mp:File = new File();
    mp = mp.resolvePath('native\path\to\mediaplayer.exe');

    nativeProcessStartupInfo.executable = mp;

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

    args.push('mySong.mp3');

    nativeProcessStartupInfo.arguments = args;

    var process:NativeProcess = new NativeProcess();

    process.start(nativeProcessStartupInfo);

}

Also make sure your app.xml contains the following:

<supportedProfiles>extendedDesktop</supportedProfiles>
+7
source

AIR 2.0, . http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/desktop/NativeProcess.html

, .air, , NativeProcess ( adt AIR SDK). , . NativeProcess.

+2

Source: https://habr.com/ru/post/1760507/


All Articles