Shelled Command Line Not Visible

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John Baker

    #1

    Shelled Command Line Not Visible

    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:


    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

  • ByteMyzer

    #2
    Re: Shelled Command Line Not Visible

    "John Baker" <wbua.onxre@wzw freivprf.pbz> wrote in message
    news:ZvX_d.5857 $h22.1098@fe1.c olumbus.rr.com. ..[color=blue]
    > I have an Access frontend that controls the running of several MS SQL[/color]
    Server DTS packages (among other things).[color=blue]
    >
    > I dynamically build a command line for dtsrun, and then use the ShellWait[/color]
    command from here:[color=blue]
    > http://www.mvps.org/access/api/api0004.htm
    >
    > The problem is that some of the packages take quite some time to execute,[/color]
    and no window appears to give the feedback[color=blue]
    > that dtsrun usually gives.
    >
    > I tried writing the dtsrun command line out to a .cmd file and then[/color]
    running that with ShellWait, but the behavior is[color=blue]
    > exactly the same.
    >
    > Advice appreciated.
    > --
    > To Email Me, ROT13 My Shown Email Address
    >[/color]

    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 GetExitCodeProc ess 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_I NFORMATION = &H400

    Public Sub ShellWait(PathN ame As String, Optional WindowStyle As Long =
    vbMinimizedFocu s)

    Dim bInheritHandle As Long
    Dim dwProcessId As Long
    Dim lpExitCode As Long
    Dim lpRetVal As Long

    bInheritHandle = Shell(PathName, WindowStyle)
    dwProcessId = OpenProcess(PRO CESS_QUERY_INFO RMATION, False,
    bInheritHandle)

    Do
    lpRetVal = GetExitCodeProc ess(dwProcessId , lpExitCode)
    DoEvents
    Loop While lpExitCode = STILL_ACTIVE And lpRetVal > 0

    If lpRetVal = 0 Then Debug.Print Err.LastDllErro r

    End Sub

    '----<< end code>>----


    Comment

    Working...