节点Webkit子生成错误UNKNOWN [英] Node-webkit child spawn UNKNOWN error
问题描述
我正在尝试在Windows文件系统上的其他位置启动.exe.
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
});
我已将其包装在try/catch中,但收到的错误没有帮助:
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"
我已经确认.exe的path.join是正确的.
I've confirmed that the path.join to the .exe is correct.
我也尝试过
game.process.stdout.on('error'...
但是永远不会触发.
编辑,我也尝试了另一种方法:
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);
}
);
但这只是具有相同代码的错误,就像在调用spawn函数的回调之前引发了try/catch块错误.
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.
有趣的是,我尝试在同一目录中调用.exe,它确实可以工作...
Interestingly I've tried calling a .exe in the same directory and it does work...
推荐答案
目标.exe选中了以管理员身份运行该程序".为了使node-webkit能够执行它,我的节点应用程序也必须以管理员身份运行.
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.
这篇关于节点Webkit子生成错误UNKNOWN的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!