I'm trying to call an exe file using childprocess.execFile. It is not throwing any errors but also not returning any result, which is printed when I run the exe directly from command line. Code:
var exec = require('child_process').execFile;
var result = '';
var child = exec('file.exe', ['-arg1'], function(err, d) {
console.log('err: '+err)
console.log(d.toString());
});
child.stdout.on('data', function(data) {
result += data;
});
child.on('close', function() {
console.log(result);
});
Try below code and also check path of file
const { execFile } = require('child_process');
const child = execFile('file.exe', ['-arg1'], null, (error, data) => {
if(error) {
console.log(error);
}
console.log(data);
});
/....code..../
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.