May12
May12

Reputation: 2520

How to ask javascript to wait an end of executing external application?

Colls, hello. My javascript run an external .bat file:

var objShell = new ActiveXObject("Shell.Application");
        objShell.ShellExecute("start.bat", "Main.bat c:\pr  ext.dat ", "C:\\PR\\", "open", "1");

Start.bat file works five minutes. And after that my script continue execute other commands. My question is «how to ask (let him know) javascript to wait an end of executing Start.bat file?»

The naxt code is not very suitable in my case:

var date = new Date();
var curDate = null;

do { curDate = new Date(); } 
while(curDate-date < millis);

Upvotes: 1

Views: 1680

Answers (1)

Teemu
Teemu

Reputation: 23416

If you're sure about the time your Main.bat needs to execute, you can use this:

WScript.Sleep(50000);

WSH Language reference: http://msdn.microsoft.com/en-us/library/98591fh7(v=vs.84).aspx

Sleep method: http://msdn.microsoft.com/en-us/library/6t81adfd(v=vs.84).aspx

Upvotes: 0

Related Questions