Javascript 在node.js中生成子进程
在Javascript 在node.js中生成子进程,javascript,node.js,Javascript,Node.js,在node.js中,我试图生成一个子进程 在执行exe文件时,我还必须传递一个参数(mode=All) 我按照下面的方法做,但什么也得不到 `var exec = require('child_process').execFile; var fun =function(){ exec('Sample.exe mode=All', function(err, data) { console.log(err) console.log(data
node.js
中,我试图生成一个子进程
在执行exe文件时,我还必须传递一个参数(mode=All
)
我按照下面的方法做,但什么也得不到
`var exec = require('child_process').execFile;
var fun =function(){
exec('Sample.exe mode=All', function(err, data) {
console.log(err)
console.log(data.toString());
});
}
fun();`
在命令行中,我得到的输出为
`c:\files\Sample.exe mode=All`
输出如下
{"ID":"VM-WIN7-64","OS":"Windows 7"}{"ID":"VM-WIN7-32","OS":"Windows 7"}{"ID":"V M-WIN7-32-1","OS":"Windows 7"}{"ID":"VM-WIN7-32-2","OS":"Windows 8"}
如何使用node.js获得上述输出?以下是文档中的
execFile
函数签名:
child_process.execFile(file, args, options, callback)
您正在将可执行文件路径与一个空格和一个参数组合在一起。execFile
并不期望这样。根据文档进行尝试:
exec('Sample.exe', ['mode=ALL'], {}, function(err, data) {