Run Multiple Instances of a LabVIEW Executable Simultaneously

Updated Nov 20, 2023

Environment

Software

  • LabVIEW

By default, executables built by LabVIEW are singletons which you can only have one instance open at a time. If you double-click the executable while an instance is already running, it simply opens up the already running executable.

This article outlines the steps to change the default setting from running a single instance to multiple instances.

When a LabVIEW executable is run for the first time, it creates a .ini file in the same directory and is named the same as the executable itself. To allow running multiple instances you will need to add a line to the .ini config file that is created after running a LabVIEW executable. By adding this line to the .ini file, you can enable the launching of multiple instances of the corresponding executable. The line is:
allowmultipleinstances = TRUE
There are three methods to add this line:
  1. Call LV Config Write Boolean.vi when the executable is executed
  2. Manually edit the created INI config file
  3. Use a custom configuration file when building an executable file
 

Call LV Config Write Boolean.vi when the executable is executed

If you would like the parameter programmatically added when executing the executable, you can consider this method.
  1. The LV Config Write Boolean.vi is a hidden API in LabVIEW, to use it, you will need to navigate to C:\<Program Files>\National Instruments\<LabVIEW Version>\resource\dialog\lvconfig.llb and add LV Config Write Boolean.vi from the library to the LabVIEW block diagram.
  2. Add string constant and boolean constant as input to the API. The boolean constant is set to True and the String constant is set to allowmultipleinstances as shown below:
allowmultinstance.JPG
This code will update the executable INI file with the specified parameter when the executable runs for the very first time. After this, any subsequent launch of the executable will utilize the allowmultipleinstances parameter.
  1. Build your executable and execute it once. The executable now should be allowed to execute multiple instances.

Back to Index
 

Manually edit the created INI config file

In this method, you will manually edit the created INI config file to add or change a parameter.
  1. Build a LabVIEW executable.
  2. Run the executable one time. Observe that a .ini config file is created in the same directory as the executable.
  3. Close the execution of the application and open the configuration .ini file.
  4. Add the following line to the .ini file beneath the [<Application_Title>] line, where <Application_Title> is the name of your executable (i.e. <Application_Title>.exe): 
    allowmultipleinstances = TRUE
  5. Save and close the .ini file.
  6. You can now run multiple instances of this application simultaneously
Back to Index


Use a custom configuration file when building an executable file

You can automate the process of adding tokens to the .ini file, by selecting a custom configuration file in the Build Specifications Properties box in your project. The option will be in the Pre/Post Build Action category. 
  1. Select require Post build VI as shown below:
Post-build
You can generate the template VI and edit it if you do not have any by pressing the Generate VI button.
  1. Modify the template VI as shown below to enable the allowmultipleinstances parameter.
code
  1. Build the executable. The generated .ini config file for the executable should show the below parameter:
allowmultipleinstances = TRUE

Back to Index
 

Additional Information

Some functions like Queues or Semaphores are only valid inside the process in which they were created. In the LabVIEW Development Environment, all VIs are running in the same process. When those VIs are built into an executable, each instance of the executable will run in its own process. For more information, read Will LabVIEW Queues or Semaphores Work Between Executables?