Running shell commands via script - Pausing Execution

I have a script that runs an EXE file via a shell command, then, when finished, runs a batch file. The problem is that the batch file starts prior to the EXE finishing. How can I include code to ensure that the EXE has finished before the batch file starts?

Thanks in advance

Dim result As Integer

result = Shell("m:\myprogram.exe", 1)

REM {Send Email to IT}

Dim Session As New NotesSession

Dim db As New NotesDatabase("" , "names.nsf") 

Dim mdoc As NotesDocument	

Set mdoc = db.createdocument

mdoc.form = "Memo"

mdoc.Sendto = "user1@mydomain.com"

mdoc.Copyto = "user2@mydomain.com"

mdoc.subject = session.commonusername & " updated his/her workstation"

mdoc.send False



Dim result2 As Integer

result2 = Shell("m:\mybatchfile.bat", 1)

REM {Send Email to IT}

Dim S As New NotesSession

Dim db2 As New NotesDatabase("" , "names.nsf") 

Dim mdoc2 As NotesDocument	

Set mdoc2 = db2.createdocument

mdoc2.form = "Memo"

mdoc2.Sendto = "user1@mydomain.com"

mdoc2.Copyto = "user2@mydomain.com"

mdoc2.subject = session.commonusername & " ran the batch file for his/her workstation"

mdoc2.send False

Subject: Running shell commands via script - Pausing Execution

Maybe,

http://www-10.lotus.com/ldd/nd6forum.nsf/55c38d716d632d9b8525689b005ba1c0/fa01121681b449668525707a0041364e

JYR

Subject: Running shell commands via script - Pausing Execution

So you need a return code from the program then, right? So that your script “blocks” until the program has finished running (synchronous vs. asynchronous).

Does this really pertain to “All Platforms” or is it Win/32? Because if it is, you may be able to use this → to do it if the program you’re calling provides any return code.

dgg

Subject: Running shell commands via script - Pausing Execution

Jonathan:

Here’s what I’ve done in the past - it may help.

If the exe file is producing file output that the batch file then reads, you script can

  1. wait - 1 sec?

  2. check for the existence of the file with a file length > 0

  3. loop to step 1

when the file is out there, then exit the loop and run the batch file

If nothing is produced by the exe, then you can try to activateapp that shellid until its done and won’t let you, then run the batch file.

Without knowing what the exe file or the batch file do, how long either takes to run, or if there it’s difficult to give a complete answer.

You may be able to get away with arbitrary waits if you’re sure of the timing

You might also run a batch file that runs both the exe and the first batch file and just send one message.

HTH

Don

Subject: RE: Running shell commands via script - Pausing Execution

In my case, the EXE will not need to return anything. I’ll take the simple approach and just merge the two commands into a single batch file. This will limit me to one message but that part isn’t a killer.

Thanks for the suggestions everyone.