
Sequential run of DOS program via SHELL command
: I need to run a DOS EXE file and then call a Windows apllication next.
: According to what I make of VB use of the SHELL command would look like
: the way to go on this. Shell, however, doesn't necessarily wait for what
: is running to complete before the next piece of code executes. If I use
: the following piece of code there is no guarentee that program1 completes
: execution before program2 begins.
: dim x,y
: x=SHELL("program1")
: y=SHELL("program2")
: So, what I need to do is make sure program1 executes and is completed
: before program2 activates. Anyone have any ideas?
Option Explicit
Declare Function GetModuleUsage% Lib "Kernel" (ByVal hModule%)
Sub Wait (x As Integer)
' Wait is called after you shell out and would like to wait for
' that external procedure or application to finish.
' x is the variable that was assigned the shell call.
While GetModuleUsage(x) > 0
DoEvents
Wend
End Sub
To call this use the something like the following:
Sub Form_Load()
Dim x As Integer
x = shell("sample.exe")
Call Wait(x)
Debug.Print "Shelled program is done!"
End Sub
BTW I found the meat of this sub in a KB article which unfortunately I forgot
its title but it went something like "How to determine when a shelled
program is complete .
Good luck,
--
****************************************************************************
Ed Hernandez North Broward Hospital District
Interface Programmer 1608 Andrews Ave.
***************************************************************************