Tutorial: system.launchExternalProcess

system.launchExternalProcess

Runs an executable or batch file.

Examples

Basic Example

fin.desktop.System.launchExternalProcess({
        path: "notepad",
        arguments: "",
        listener: function(code) {
                console.log('the exit code', code);
            }
    },
    function() {
        console.log('all good');
    },
    function(){
        console.log('an error');
    });

Listener callback

//This response has the following shape:
{
    uuid: "FB3E6E36-0976-4C2B-9A09-FB2E54D2F1BB" //The mapped UUID which identifies the launched process
}

Example using an alias from app.json appAssets property

"appAssets": [
    {
    "src": "exe.zip",
    "alias": "myApp",
    "version": "4.12.8",
    "target": "myApp.exe",
    "args": "a b c d"
    },
]
/*
When called, if no arguments are passed then the arguments (if any)
are taken from the 'app.json' file, from the  'args' parameter
of the 'appAssets' Object with the relevant 'alias'.
 */
fin.desktop.System.launchExternalProcess({
        //Additionally note that the executable found in the zip file specified in appAssets
        //will default to the one mentioned by appAssets.target
        //If the the path below refers to a specific path it will override this default
        path: "myApp",
        listener: function(code) {
                console.log('the exit code', code);
            }
    },
    function() {
        console.log('all good');
    },
    function(){
        console.log('an error');
    });

Example using an alias but overridding the arguments

"appAssets": [
    {
    "src": "exe.zip",
    "alias": "myApp",
    "version": "4.12.8",
    "target": "myApp.exe",
    "args": "a b c d"
    },
]
/*
If 'arguments' is passed as a parameter it takes precedence
over any 'args' set in the 'app.json'.
 */
fin.desktop.System.launchExternalProcess({
        path: "myApp",
        arguments: "e f g",
        listener: function(code) {
                console.log('the exit code', code);
            }
    },
    function() {
        console.log('all good');
    },
    function(){
        console.log('an error');
    });