【发布时间】:2016-03-14 10:47:20
【问题描述】:
我正在将 Node Webkit 用于我的 Web 应用程序,而且我真的是使用 Node Webkit 的新手。我想在我的应用程序中运行我的 exe,但我什至无法使用“child_process”打开简单的记事本。我在网站上看到了一些示例,但我仍然发现很难运行 notepad.exe,请帮助并提前非常感谢。
var execFile = require
('child_process').execFile, child;
child = execFile('C:\Windows\notepad.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);
});
child.on('exit', function (code) {
console.log('Child process exited '+
'with exit code '+ code);
});
我还尝试使用 meadco-neptune 插件运行 exe 并添加插件,我将代码放在 package.json 文件中,但它显示无法加载插件。我的 package.json 文件是这样的
{
"name": "sample",
"version": "1.0.0",
"description": "",
"main": "index.html",
"window": {
"toolbar": false,
"frame": false,
"resizable": false,
"show": true,
"title": " example"
},
"webkit": {
"plugin": true
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "xyz",
"license": "ISC"
}
【问题讨论】:
-
Docs 表示“
callback- 进程终止时使用输出调用的函数”。 记事本不会自行终止
标签: node.js webkit exe node-webkit