"John Baker" <wbua.onxre (AT) wzwfreivprf (DOT) pbz> wrote
Quote:
I have an Access frontend that controls the running of several MS SQL
Server DTS packages (among other things).
I dynamically build a command line for dtsrun, and then use the ShellWait
command from here:
http://www.mvps.org/access/api/api0004.htm
The problem is that some of the packages take quite some time to execute,
and no window appears to give the feedback
that dtsrun usually gives.
I tried writing the dtsrun command line out to a .cmd file and then
running that with ShellWait, but the behavior is
exactly the same.
Advice appreciated.
--
To Email Me, ROT13 My Shown Email Address |
One disadvantage to using the method implemented in the above link is that
it does not return control back to your code until the Shelled process has
finished execution. The following ShellWait function runs asynchronously,
giving the option to enumerate the process status within the code:
'---<< begin code>>---
Option Explicit
Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess
As Long, lpExitCode As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess
As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Const STILL_ACTIVE = &H103
Private Const PROCESS_QUERY_INFORMATION = &H400
Public Sub ShellWait(PathName As String, Optional WindowStyle As Long =
vbMinimizedFocus)
Dim bInheritHandle As Long
Dim dwProcessId As Long
Dim lpExitCode As Long
Dim lpRetVal As Long
bInheritHandle = Shell(PathName, WindowStyle)
dwProcessId = OpenProcess(PROCESS_QUERY_INFORMATION, False,
bInheritHandle)
Do
lpRetVal = GetExitCodeProcess(dwProcessId, lpExitCode)
DoEvents
Loop While lpExitCode = STILL_ACTIVE And lpRetVal > 0
If lpRetVal = 0 Then Debug.Print Err.LastDllError
End Sub
'----<< end code>>----