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
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.
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.