我正在使用 Node Webkit 组件来包装我的 html5 应用程序。 在此应用程序中,我需要运行 CMD 或其他 (exe) 文件,如“customApplication.exe”并传递一些参数。
我对这件事真的很绝望。如果你能帮助我,我会很高兴。这非常重要,我不想更改我的组件并使用 Awesomium 或其他组件。
非常感谢您。
最佳答案
希望此示例代码对您有所帮助。 (它摘 self 最近对 node-webkit 的电子书介绍。) 您需要将变量“filePath”设置为“customApplication.exe”的完整路径
var execFile = require
('child_process').execFile, child;
child = execFile(filePath,
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);
});
child.on('exit', function (code) {
console.log('Child process exited '+
'with exit code '+ code);
});
祝你好运
乔纳森·多德
“使用 node-webkit 创建 Windows 桌面应用程序”
关于html - Node Webkit - 如何执行 exe 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18183882/