HOW: waiting for Shell process to complete?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rob Lemieux

    HOW: waiting for Shell process to complete?

    In my code...

    Dim intFNum As Integer
    Dim ID As Integer
    intFNum = FreeFile
    Open "runme.bat" For Output As #intFNum
    Print #intFNum, "dir > log.txt"
    Close #intFNum
    ID = Shell(fileName, vbNormalFocus)

    I want to wait until the log.txt file is read for reading.
    I don't want to specify a time, because some computers run very slow, others
    fast.

    Thanks.



  • Slaatje

    #2
    Re: waiting for Shell process to complete?


    Private Const CREATE_NO_WINDO W = &H8000000
    Public Sub ExecCmd(cmdline $)
    Dim proc As PROCESS_INFORMA TION
    Dim START As STARTUPINFO
    Dim ret As Long
    ' Initialize the STARTUPINFO structure:
    START.cb = Len(START)
    ' Start the shelled application:
    ret = CreateProcessA( &O0, cmdline$, 0&, 0&, 1&, _
    NORMAL_PRIORITY _CLASS + CREATE_NO_WINDO W, 0&, 0&, START, proc)
    If ret Then
    ' Wait for the shelled application to finish:
    ret = WaitForSingleOb ject(proc.hProc ess, INFINITE)
    End If
    CloseHandle (proc.hProcess)
    End Sub


    Rob Lemieux heeft geschreven in bericht ...[color=blue]
    >In my code...
    >
    > Dim intFNum As Integer
    > Dim ID As Integer
    > intFNum = FreeFile
    > Open "runme.bat" For Output As #intFNum
    > Print #intFNum, "dir > log.txt"
    > Close #intFNum
    > ID = Shell(fileName, vbNormalFocus)
    >
    >I want to wait until the log.txt file is read for reading.
    >I don't want to specify a time, because some computers run very slow,[/color]
    others[color=blue]
    >fast.
    >
    >Thanks.
    >
    >
    >[/color]


    Comment

    Working...