Psl*_*Psl 3 javascript node.js
在node.js我试图产生一个子进程
我也必须(mode=All在执行exe文件时传递参数
我是按照以下方式做的.但是没有得到任何东西
`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();`
Run Code Online (Sandbox Code Playgroud)
在命令行中输出为
`c:\files\Sample.exe mode=All`
Run Code Online (Sandbox Code Playgroud)
输出如下
{"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"}
Run Code Online (Sandbox Code Playgroud)
如何使用node.js获得上述输出
这是execFile文档中的函数签名:
child_process.execFile(file, args, options, callback)
Run Code Online (Sandbox Code Playgroud)
您将可执行文件路径与空格和参数组合在一起.在execFile并不预期.根据文档尝试:
exec('Sample.exe', ['mode=ALL'], {}, function(err, data) {
Run Code Online (Sandbox Code Playgroud)