使用node.js执行一个exe文件

我不知道如何在node.js执行一个exe文件。 这是我正在使用的代码。 它不工作,不打印任何东西。 有没有任何可能的方式来执行一个exe文件使用命令行?

 var fun = function() { console.log("rrrr"); exec('CALL hai.exe', function(err, data) { console.log(err) console.log(data.toString()); }); } fun(); 

您可以尝试node.js中的subprocess模块的execFile函数

请参阅: 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();