我使用 node.js v4.4.4,我需要从 node.js 运行 .bat
tài liệu.
从我的 Node 应用程序的 js 文件的位置,.bat 可以使用具有以下路径(Window 平台)的命令行运行:
'../src/util/buildscripts/build.bat --profile ../profiles/app.profile.js'
但是当使用 Node 时我无法运行它,没有抛出特定的错误。
Tôi đang làm gì sai ở đây?
var ls = spawn('cmd.exe', ['../src/util/buildscripts', 'build.bat', '--profile ../profiles/app.profile.js']);
ls.stdout.on('data', function (data) {
console.log('stdout: ' + data);
});
ls.stderr.on('data', function (data) {
console.log('stderr: ' + data);
});
ls.on('exit', function (code) {
console.log('child process exited with code ' + code);
});
你应该能够运行这样的命令:
var child_process = require('child_process');
child_process.exec('path_to_your_executables', function(error, stdout, stderr) {
console.log(stdout);
});
Tôi là một lập trình viên xuất sắc, rất giỏi!