0

I have a .bat file with multiple lines. Each line corresponds to a different process. I could find a way to run the whole .bat file via javascript. What I really want to do is run each line/process given in the .bat file find the time it takes to execute each process. Can someone help me, please?

This is the code I use to run the whole .bat file

function loadTime() {
    var exec = require('child_process').exec;
    exec('C:\\Temp\\tasks\\acis\\runme.bat', function(error, stdout, stderr) {
        console.log('stdout: ' + stdout);
        if (error !== null) {
            console.log('exec error: ' + error);
        }
    });
}
Dan Lowe
  • 51,713
  • 20
  • 123
  • 112
TMA
  • 111
  • 1
  • 2
  • 9
  • Have you tried to open and read the bat file [one line at a time](http://stackoverflow.com/questions/6156501/read-a-file-one-line-at-a-time-in-node-js/32599033#32599033) and then passing each line string to `exec` instead of the whole batch file ? – traktor Oct 19 '15 at 00:52
  • Could this be done via javascript? It could be easily done with a Batch file... Do you want a WSH JScript.js solution? – Aacini Oct 19 '15 at 01:49
  • Thanks for the responses guys. @ Aacini, yes I have to do it via Javascript. Yes, and I would be very much interested in WSH JScript.js solution. Thanks – TMA Oct 19 '15 at 02:00
  • @Traktor53: Can you show me how to implement your solution? Thanks – TMA Oct 19 '15 at 02:34
  • Sorry, I do not wish to write code for you - it might involve promises or if not, "async callback hell". My comment was a question. – traktor Oct 19 '15 at 04:19

0 Answers0