Launch a window application and wait for complete

Posted on 2006-03-23
Last Modified: 2010-04-23
Hi Expert,

Following code works fine if I want to launch an application program:

Sub LaunchApplication()
    Dim iAppID As Integer = Shell(appPath, AppWinStyle.MaximizedFocus)
    If System.IO.File.Exists(appPath) = True Then
End Sub

However, If I want to launch an application and force the operation system to wait until the application has been terminated before allowing any other action to be performed.  How do I do?  I  heard of ExecuteAndWait method. How does that work?  The code will be in form_load event.

Thanks very much

Question by:heartland
    LVL 69

    Expert Comment

    by:Éric Moreau
    Hi heartland,

    It is WaitForExit. See an article I wrote in December 2003 from

    LVL 62

    Accepted Solution

    Hi heartland;

    The below code should do what you want.

    Imports System.Diagnostics

    Sub LaunchApplication()
        If System.IO.File.Exists(appPath) = True Then
            Dim p As Process
            p = Process.Start(appPath)
    End Sub


    Author Comment

    Hi Fernando,

    I tried your code and it did the exactly what I wanted.  It is concise too.  Thanks for help.

    LVL 62

    Expert Comment

    by:Fernando Soto
    Glad I was able to help. :=)

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
    Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now