title: How do I run an external file within Gulp?
body: <p>At the moment I'm using the <a href="https://github.com/cbarrick/gulp-run" rel="noreferrer">"gulp-run" plugin</a> to run a .bat file. That plugin has now been deprecated and I'm looking for the best way to execute the .bat now.</p>
  
  <p><strong>Current code:</strong></p>
  
  <pre><code>var gulp = require('gulp');
  var run = require('gulp-run');
  
  module.exports = function() {
  
      run('c:/xxx/xxx/runme.bat').exec();
  
  };
  </code></pre>
  
  <p><strong>Solution</strong> as per @cmrn suggestion:</p>
  
  <pre><code>var exec = require('child_process').exec;
  var batchLocation = 'c:/xxx/xxx/runme.bat';
  gulp.task('task', function (cb) {
    exec(batchLocation, function (err, stdout, stderr) {
      console.log(stdout);
      console.log(stderr);
      cb(err);
    });
  })
  </code></pre>