12-27-2019 10:49 PM
Hello folks,
I have a LabVIEW executable (.exe) file that I am trying to read inputs into/outputs using Python. I do not have the original VI, and it seems that the enable ActiveX server option was not enabled during the build process of the .exe file. This is because I get an error when I run the below code snippet:
import win32com.client
LabVIEW = win32com.client.Dispatch("Mirror.Application")
Error: com_error: (-2147221005, 'Invalid class string', None, None)
I have already run the Mirror.exe file as an administrator, to try to ensure system registration. I have used Python previously to talk to LabVIEW VI/exe files, but those VI's were written and built into .exe files by me, with the "Enable ActiveX Server" box checked. Never had any issues.
So, if ActiveX server was not enabled during building the VI into a .exe file, is there any way to do that with only the executable file? Would appreciate any advice!
Thanks,
12-28-2019 06:42 AM
Have you tried to edit the ini file for your executable to add following entries:
Server.ole.enabled=True
Server.app.propertiesEnabled=True
Server.vi.propertiesEnabled=True
Server.vi.callsEnabled=True
That should be enough I think but you still will need to know the VI names inside the executable and the control names to pass parameters to them and read the return parameters back!
12-29-2019 03:54 PM
Hello Rolf,
I did try editing the .ini file as suggested. I only added the server.vi.callsEnabled = True entry, as the first three entries you mentioned were already in the .ini file. However, I still cannot call the .exe file from Python, even after running the .exe file as an administrator again.
I also did a test where I wrote a simple VI that adds two numbers, and built the VI into two .exe files, one with ActiveX server enabled, and one without. I had a look at the .ini files of both builds, and they were exactly the same. Here is a print:
server.app.propertiesEnabled=True
server.ole.enabled=True
server.tcp.serviceName="My Computer/VI Server"
server.vi.propertiesEnabled=True
WebServer.TcpAccess="c+*"
WebServer.ViAccess="+*"
DebugServerEnabled=False
DebugServerWaitOnLaunch=False
I did notice that when the ActiveX server was enabled, a .tlb file was generated. Perhaps I have to try to generate the .tlb file by just using the .exe file I have? Please let me know what you think.
Best,
12-30-2019 08:34 AM - edited 12-30-2019 08:40 AM
I'm not sure the tlb file is really important but it seems the executable has a tiny small modification in its binary data when it is created with and without ActiveX enabled. Seems like there would need to be a single bit flipped somewhere that is taken care of by the application builder.
So it may be actually impossible without a serious amount of reverse engineering of the LabVIEW resource file format, which is embedded in the resource stream inside the executable.
Also you can't create the tlb file from the executable. It is in addition to the executable describing the methods and properties of the process. The tlb file could be embedded in the executable but it works also if alongside the executable. It is most likely an almost verbatim copy of the labview.tlb file in the LabVIEW resources folder.
01-08-2020 01:38 PM
Hello Rolf,
Thanks for the leads. I ended up using PyAutoGui (python library to manipulate mouse & keyboard) to control the front panel of the .exe file to write/read parameter values. It is a bit of a band-aid, but worked for what I wanted to do.
Thanks,