Click here to Skip to main content
15,790,565 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a Windows Form Application (appLoader.exe) where I used to Shell another .exe file (TestApp.exe). When I Shell the TestApp.exe file, the application will run but when I closed the appLoader.exe, the other app will still running. How to end the process of the TestApp.exe if the appLoader.exe is closed?

What I have tried:

So far, I only do the shell coding to open the TestApp.exe
Updated 10-Jun-23 9:57am

1 solution

Rather than using Shell, which is only provided for backwards-compatibility with VB6, use Process.Start[^]. That will return a Process[^] object which you can use to monitor the external process.

If the external application has a user interface, you can then call CloseMainWindow[^] to close the application gracefully. Otherwise, you can call Kill[^] to immediately terminate the application. However, be aware that this will not give the application a chance to shut down properly, and may result in data loss.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900