Hir*_*koo 1 html5 node.js node-webkit
我正在使用Node Webkit组件来包装我的html5应用程序.在这个应用程序中,我需要运行CMD或其他(exe)文件,如"customApplication.exe"并传递一些参数.
在这件事上我真的很无望.如果你能帮助我,我会很高兴的.这非常重要,我不想更改我的组件并使用Awesomium或其他组件.
非常感谢你提前.
小智 7
我希望这个示例代码会有所帮助.(它取自我最近对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);
});
Run Code Online (Sandbox Code Playgroud)
祝你好运,
乔纳森多德
"使用node-webkit创建Windows桌面应用程序"