Выполните exe файл, используя node.js
Я не знаю, как выполнить файл exe
в node.js
. Вот код, который я использую. Он не работает и ничего не печатает. Есть ли способ выполнить файл exe
с помощью командной строки?
var fun = function() {
console.log("rrrr");
exec('CALL hai.exe', function(err, data) {
console.log(err)
console.log(data.toString());
});
}
fun();
Ответы
Ответ 1
вы можете попробовать функцию execFile дочерних модулей процесса в node.js
См:
http://nodejs.org/api/child_process.html#child_process_child_process_execfile_file_args_options_callback
Код должен выглядеть примерно так:
var exec = require('child_process').execFile;
var fun =function(){
console.log("fun() start");
exec('HelloJithin.exe', function(err, data) {
console.log(err)
console.log(data.toString());
});
}
fun();