To execute an exe file using Node, we use the execfile
method.
For instance, we write
const exec = require("child_process").execFile;
exec("hello.exe", (err, data) => {
console.log(err);
console.log(data.toString());
});
to call exec
run to hello.exe.
We get the output from data
and errors from err
in the callback.