2013-11-04 2 views
19

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(); 

답변

31

당신은 Node.js를

에서 자식 프로세스 모듈의 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(); 
관련 문제