Closing the Front Panel of an Executable Programmatically

Updated Mar 14, 2023

Environment

Software

  • LabVIEW Application Builder Module
  • LabVIEW

I have an executable that was build with the LabVIEW Application Builder, and I want the application to close when it is finished running. I tried enabling options to Show Front Panel When Called and Close Afterwards if Originally Closed under VI Setup » Execution Options, but they didn't have any effect. How can I get my application to close when it's finished running?

 

The VI Setup options for Show Front Panel When Called and Close Afterwards if Originally Closed will only affect a VI when it is called as a subVI, not as the main VI. The same holds true when you build a VI into an executable.

You can make use of the Close FP method to close your VI's front panel at any point in your program by following these steps:
  1. Place an Open VI Reference function on the block diagram. This function can be found in the functions palette by going to Programming » Application Control » Open VI Reference.
  2. Right-click the VI Path input and go to Create » Constant. Enter the name of this VI into the constant.
  3. Place an invoke node on the block diagram at the point in your program where you want the front panel to close. This function can be found in the functions palette be going to Programming » Application Control » Invoke Node. 
  4. Wire the output of the Open VI Reference into the invoke node.
  5. Click the invoke node and select Front Panel » Close. 
  6. Run your VI. When the program reached the invoke node, your VI will close. This will work the same way when your VI is built as an executable. 
The following example shows this implementation with a button to trigger closing your front panel. The testclose.exe application in the attachments below shows this behavior in executable form. 


Additional Information

For versions of LabVIEW before 7.0, you will need to use the Quit LabVIEW function to make your executable's front panel programmatically close. This function is located in your functions palette under Application Control. The disadvantage in this approach is that all LabVIEW executables that are open will close at the time this function is called.