Connect to a LabVIEW VI And Executable From Python

Updated Mar 13, 2024

Reported In


  • LabVIEW

Programming Language

  • Python


  • Python

Issue Details

I would like to connect to a running VI or executable built from a VI and control or get Front Panel values using Python.
How can I do that?


This can be achieved with ActiveX methods and properties.

To do so you can utilize the win32com and pywin32 modules in your Python code. The following code connects to a running VI specified by a path and returns the value of a control called "main".

import win32com.client

labview = win32com.client.Dispatch("Labview.Application")
VI = labview.getvireference(r'c:\TEMP\ctrl\')
print(f'Name: {VI.Name}')
If you would like to connect to a built executable you have to modify the dispatch application parameter and also the path of the VI will be added as an extra layer to the reference path:
import win32com.client

labview = win32com.client.Dispatch("ctrl.Application")
VI = labview.getvireference(r'c:\TEMP\ctrl\Ctrl.exe\')

print(f'Name: {VI.Name}')

Additional Information

The solution above utilizes ActiveX. 

In order to connect to your executable, you must Enable ActiveX server on the Advanced Page (Application Properties Dialog Box) under Build Specifications. You may also need to enable VI server settings for your project before creating your executable.

If your LabVIEW code includes user interface events, consider switching to custom events as the first ones won't be triggered programmatically