Stop a Running LabVIEW Application When Another LabVIEW Application Starts

Updated Oct 25, 2020



  • LabVIEW
  • LabVIEW Application Builder Module

  • I have a built application that I need to automatically stop when a different application starts.
  • How can I stop a LabVIEW application from another one programmatically? 
  • Is it possible to stop an application from another one? 
  • I have two applications that communicate with the same hardware device, and I need one of them to stop when the second one starts. 
  • Can I stop a Windows application from a LabVIEW application?

There is more than one way to solve this problem. In this article, we are providing two out of potentially many solutions that could provide this functionality. In this article, APP1.exe is the application that is initially running, and APP2.exe is the application that is started in second place and halts APP1's execution.  

1) The first option is two "kill" APP1.exe programmatically from APP2.exe by calling a Windows Command Prompt and executing a taskkill command from within the Block Diagram. This is a straightforward procedure, but it is only recommended to be used if and only if there are no critical physical or software processes that could be affected by stopping APP1.exe. An example of the code is shown below, this example is used to stop the APP1.exe process in Windows. Instead of APP1.exe, check what your Windows or LabVIEW application name is in Windows Task Manager and replace it in the code. 
2) The second option, only applies to the case of a LabVIEW application stopping another LabVIEW application already running. The solution would be to create a text file that resides in a folder that is accessible by both applications. The logic flow of this solution could be the following or similar:
  1. The text file will only contain either a 0 or a 1. A number 1 written to the file will stop APP1.exe, while a 0 written to the file allows APP1 to execute. 
  2. APP1.exe can only read from the text file
  3. APP2.exe can only write from the text file
  4. Once APP2 starts, it temporarily writes a 1 to the shared text file
  5. APP1 is constantly reading from the file, and when it detects a 1, it stops its execution
  6. APP2 writes back a number 0 to the text file, so APP1 may execute again in the future

Example screenshots of both application's code are shown below:

1) Application 1, reads from text file:


2) Application 2, writes to the same text file: 

Note: These provided solutions are not exhaustive, and other solutions might be explored as well. 

Additional Information

Another potential solution is to use a shared Global Variable among the applications.