2016-05-10 201 views
1

我想运行一个脚本保存在/public/run.bat在我的流星项目目录中。执行一个批处理脚本服务器端流星

在/server/main.js:

'callExe': function() { 
var spawn = require('child_process').spawn, 
ls = spawn('cmd.exe', ['/c', 'run.bat']); 

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

这是我的错误,

I20160510-00:02:09.762(-4)? stderr: 'run.bat' is not recognized as an  
internal or external command, 
I20160510-00:02:09.766(-4)? operable program or batch file. 
I20160510-00:02:09.766(-4)? 
I20160510-00:02:09.794(-4)? child process exited with code 1 

虽然它运行时,我把它放在.meteor \本地\编译\程序\服务器。 有人可以帮我解决这个问题吗?

回答

1

找出run.bat文件的完整路径并使用它。例如,如果run.bat在c:\meteor\local\build\programs\public

ls = spawn('cmd.exe', ['/c', 'c:\meteor\local\build\programs\public\run.bat']); 
相关问题