Tom
Tom

Reputation: 411

how to execute batch file one by one in javascript

I have to execute two batch files in JavaScript. The following is my code:

var shell = new ActiveXObject('WScript.Shell');
shell.Run('c:\\batch1.bat');
shell.Run('c:\\batch2.bat');

What happens according to the above code is that both the batch files are executed simultaneously. However, I want the batch1.bat to execute first and then when it finishes execution then it should start with execution of batch2.bat. how can this be done in JavaScript.

Thank you in advance for your help.

Upvotes: 0

Views: 2783

Answers (1)

Sturm
Sturm

Reputation: 4285

A simple solution would be to call batch2 from batch1. They aren't executing at the same time, just very close to each other.

Also try:

result = shell.Run(stuff, true);

as shown in this post: How To Programmatically Wait For Shell Command To Finish Running?

Upvotes: 2

Related Questions