How to wait for command window to exit?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Terry Olsen

    How to wait for command window to exit?

    I have loop that calls a Sub that runs the following code:

    Dim WinZip As System.Diagnost ics.Process
    Dim args As String = " -Pru -ex " & lblFolder.Text & "\" & PCName &
    ".zip @""" & appPth & "WksBkup.tx t"""
    WinZip.Start("c :\Program Files\WinZip\wz zip.exe", args)
    WinZip.WaitForE xit()
    Do
    If WinZip.HasExite d = True Then Exit Do
    Loop
    MsgBox("suppose dly exited")

    However, it does not wait, and the message box never appears. I get
    several command windows running WinZip at simultaneously. The program
    does not block, If I click the button again, I get even more
    simultaneously running command windows. But I can't get the program to
    wait or even show me the messagebox.

    Any ideas?

    *** Sent via Developersdex http://www.developersdex.com ***
  • Ken Tucker [MVP]

    #2
    Re: How to wait for command window to exit?

    Hi,

    I prefer to use a processstartinf o for starting an application
    with arguments.



    Second Add application.doe vents to your loop so it can finish it the
    winzip.hasexite d is not true when run the first time.

    Do
    If WinZip.HasExite d = True Then Exit Do
    Application.DoE vents
    Loop

    Ken
    -------------------
    "Terry Olsen" <tolsen64@hotma il.com> wrote in message
    news:uDU2yKwkFH A.3260@TK2MSFTN GP10.phx.gbl...
    I have loop that calls a Sub that runs the following code:

    Dim WinZip As System.Diagnost ics.Process
    Dim args As String = " -Pru -ex " & lblFolder.Text & "\" & PCName &
    ".zip @""" & appPth & "WksBkup.tx t"""
    WinZip.Start("c :\Program Files\WinZip\wz zip.exe", args)
    WinZip.WaitForE xit()
    Do
    If WinZip.HasExite d = True Then Exit Do
    Loop
    MsgBox("suppose dly exited")

    However, it does not wait, and the message box never appears. I get
    several command windows running WinZip at simultaneously. The program
    does not block, If I click the button again, I get even more
    simultaneously running command windows. But I can't get the program to
    wait or even show me the messagebox.

    Any ideas?

    *** Sent via Developersdex http://www.developersdex.com ***


    Comment

    • Herfried K. Wagner [MVP]

      #3
      Re: How to wait for command window to exit?

      "Terry Olsen" <tolsen64@hotma il.com> schrieb:[color=blue]
      > Dim WinZip As System.Diagnost ics.Process
      > Dim args As String = " -Pru -ex " & lblFolder.Text & "\" & PCName &
      > ".zip @""" & appPth & "WksBkup.tx t"""
      > WinZip.Start("c :\Program Files\WinZip\wz zip.exe", args)[/color]

      => 'WinZip = Process.Start(. ..)'.
      [color=blue]
      > WinZip.WaitForE xit()
      > Do
      > If WinZip.HasExite d = True Then Exit Do
      > Loop
      > MsgBox("suppose dly exited")
      >
      > However, it does not wait, and the message box never appears.[/color]

      First, try to remove the 'Do...Loop' loop. As you are already using
      'WaitForExit' the loop is not necessary.

      --
      M S Herfried K. Wagner
      M V P <URL:http://dotnet.mvps.org/>
      V B <URL:http://classicvb.org/petition/>

      Comment

      • Terry Olsen

        #4
        Re: How to wait for command window to exit?

        I added the Do...Loop just to see what would happen because the
        'WaitForExit' is not waiting...

        However, nothing is waiting and I can't figure out why...


        "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
        news:uJtnBywkFH A.576@TK2MSFTNG P15.phx.gbl...[color=blue]
        > "Terry Olsen" <tolsen64@hotma il.com> schrieb:[color=green]
        >> Dim WinZip As System.Diagnost ics.Process
        >> Dim args As String = " -Pru -ex " & lblFolder.Text & "\" & PCName &
        >> ".zip @""" & appPth & "WksBkup.tx t"""
        >> WinZip.Start("c :\Program Files\WinZip\wz zip.exe", args)[/color]
        >
        > => 'WinZip = Process.Start(. ..)'.
        >[color=green]
        >> WinZip.WaitForE xit()
        >> Do
        >> If WinZip.HasExite d = True Then Exit Do
        >> Loop
        >> MsgBox("suppose dly exited")
        >>
        >> However, it does not wait, and the message box never appears.[/color]
        >
        > First, try to remove the 'Do...Loop' loop. As you are already using
        > 'WaitForExit' the loop is not necessary.
        >
        > --
        > M S Herfried K. Wagner
        > M V P <URL:http://dotnet.mvps.org/>
        > V B <URL:http://classicvb.org/petition/>[/color]


        Comment

        • Herfried K. Wagner [MVP]

          #5
          Re: How to wait for command window to exit?

          "Terry Olsen" <tolsen64@hotma il.com> schrieb:[color=blue]
          >I added the Do...Loop just to see what would happen because the
          > 'WaitForExit' is not waiting...
          >
          > However, nothing is waiting and I can't figure out why...[/color]

          Are you sure you made the other change I suggested?

          --
          M S Herfried K. Wagner
          M V P <URL:http://dotnet.mvps.org/>
          V B <URL:http://classicvb.org/petition/>

          Comment

          Working...