Reputation: 103
I am trying to call an exe file from the node.js with 3 parameters. Getting error as
errno: 'ENOENT'
code: 'ENOENT'
I am using 64 bit windows 10 system . Here is the code that i am using currently
var exec = require('child_process').execFile;
var opt =function(){
exec('file.EXE arg1 arg2 arg3', function(err, data) {
console.log(err)
console.log(data.toString());
});
}
opt();
Upvotes: 0
Views: 5995
Reputation: 2534
You need to separate file name and arguments.
Syntax: child_process.execFile(file[, args][, options][, callback])
var exec = require('child_process').execFile;
var opt = function(){
exec('file.EXE', ["arg1", "arg2", "arg3"], function(err, data) {
console.log(err)
console.log(data.toString());
});
}
opt();
In the following example, I'm compiling Main.java using javac.exe.
here file name is javac.exe path and Main.java is argument.
Upvotes: 3