Node-webkit child spawn UNKNOWN error

自古美人都是妖i 提交于 2019-12-10 14:39:10

问题


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:


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.



来源:https://stackoverflow.com/questions/30809808/node-webkit-child-spawn-unknown-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!