Javascript - 如何执行位于C:\的可执行文件?

Javascript - How to execute the executable file located in C:\?

对于 NW,我有以下代码。正在执行 Java 或其他脚本。但无法 运行 任何位置路径,例如以下失败。

var exec = require('child_process').exec;
function voidrun(input){
  run_void = exec(input, function (error, stdout, stderr) { 
    sys.print('stdout: ' + stdout); 
    sys.print('stderr: ' + stderr); 
    if (error !== null) { 
      console.log('exec error: ' + error);
    }
  }); 

  run_void.on('exit', function(code) {
      console.log('Child process exited '+ code);
  });  
}

function boot() {
    runme('C:\run\splashscreen.exe');  
}

试试这个:

var exec = require('child_process').exec;

var cmd = 'executable.exe parameter1 parameter2';
var path = 'c:\path';
var child = exec(
    cmd, {
        cwd: path
    },
    function(error, stdout, stderr) {
        if (error === null) {
            console.log('success');
        } else {
            console.log('error');
        }
    }
);