Sometimes, we w=ant to execute an exe file using Node.js and JavaScript.
In this article, we’ll look at how to execute an exe file using Node.js and JavaScript.
How to execute an exe file using Node.js and JavaScript?
To execute an exe file using Node.js and JavaScript, we use the child_process
module.
For instance, we write
const exec = require("child_process").execFile;
exec("hello.exe", (err, data) => {
console.log(err);
console.log(data.toString());
});
to call import execFile
and assign it to exec
.
Then we call exec
with the command string with the exe we want to run.
And we get the output from data
.
Conclusion
To execute an exe file using Node.js and JavaScript, we use the child_process
module.