Node-webkit child spawn UNKNOWN error

6.1k views Asked by At

I'm trying to launch an .exe elsewhere on my Windows filesystem.

spawn = require('child_process').spawn;

game.process = spawn(path.join(config.values.armaPath, 'arma3.exe'), {
    detached: true
});

I've wrapped it in a try/catch and the error I'm getting isn't helpful:

Error {code: "UNKNOWN", errno: "UNKNOWN", syscall: "spawn", stack: (...), message: "spawn UNKNOWN"}code: "UNKNOWN"errno: "UNKNOWN"message: "spawn UNKNOWN"

I've confirmed that the path.join to the .exe is correct.

I've also tried

game.process.stdout.on('error'...

but that never fires.

Edit, I've also tried another method:

var child = execFile(path.join(config.values.armaPath, 'arma3.exe'),
    function(error,stdout,stderr) { 
        if (error) {
            console.log(error.stack); 
            console.log('Error code: '+ error.code); 
            console.log('Signal received: '+ error.signal);
        } 
        console.log('Child Process stdout: '+ stdout);
        console.log('Child Process stderr: '+ stderr);
    }
); 

But that just errors with the same code, it's like the try/catch block error is being thrown before the callback from the spawn function is called.

Interestingly I've tried calling a .exe in the same directory and it does work...

1

There are 1 answers

0
Titan On BEST ANSWER

The target .exe had "Run this program as an administrator" ticked. In order for node-webkit to execute it, my node app also has to be run as an administrator too.