|
-
April 28th, 2000, 09:12 AM
#1
Execute batch and wait
I am trying to execute a batch. I believe I can do this. The only thing is that the batch initiates operations within in a file that will run independently of the batch. I have the code that will execute the batch and pause the rest of the program until the batch is complete but that doesn't help me since it doesn't know when the operations inside the file are complete. The type of file is an Aspentech MIMI case file. The bat file the I am executing within my program will execute the $batch macro inside of the MIMI case file. Does anyone know how to tell when the operation inside of MIMI is complete?
Here is my code thus far which I believe is correct ssince I found it here.
public sub RunBat()
shell "\\BatPath", vbNormalFocus
End Sub
Declare Function WaitForSingleObject Lib "kernel32" (byval hHandle as Long, byval dwMilliseconds as Long) as Long
Declare Function OpenProcess Lib "kernel32" (byval dwDesiredAccess as Long, byval bInheritHandle as Long, byval dwProcessId as Long) as Long
public Const INFINITE = -1
public Sub ShellWait(byval FileName as string, optional WindowStyle as Variant)
Dim idProc as Long
Dim hProc as Long
' start program and save PID
idProc = VBA.Shell(FileName, WindowStyle)
' get process handle
hProc = OpenProcess(PROCESS_ALL_ACCESS, false, idProc)
'wait till program has finished
If hProc <> hNull then
Call WaitForSingleObject(hProc, INFINITE)
Call CloseHandle(hProc)
End If
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|