无法使用argumnets运行exe文件

时间:2020-01-15 14:25:27

标签: javascript node.js

嗨,我想使用节点js的child_process运行exe文件,这是我拥有的功能:

let fs = require('fs');
let path = require('path');
const { execFileSync } = require('child_process');

let base64String = req.body.image;
let base64File = base64String.split(';base64,').pop();
let dir = '/server/html/upload';
let file = dir+'/image.png';

fs.writeFileSync(file, base64File, {encoding: 'base64'});

let exeprog = path.normalize(__dirname + '/upload/program.exe');
let imagefile = path.normalize(__dirname + '/upload/image.png');
let destfile = path.normalize(__dirname + req.body.file);

let child = execFileSync(exeprog , [imagefile, req.body.field, destfile , 'TRUE']);
res.json(child)

运行此代码时出现此错误:

Error: spawnSync C:\server\html\upload\prog.exe
EINVAL

我正在使用的 nodeJS 版本是8.15.0,并且应用程序以管理权限启动,我在代码中缺少了某些内容

0 个答案:

没有答案