​

Either its not working, or I'm doing something wrong.

Earlier I did that:

- when I builded the executable from the .vi (Labview virtual instrument), I 
had the option to enable ActiveX server.
- the name of the activeX server is "LaserX"
- after I launched the .exe file, I was able to connect to it with the 
following two lines:

labview = win32com.client.Dispatch("LaserX.Application")
VI = labview.getvireference(r'c:\path-to-exe\Controller.exe\Controller.vi')
​Now I did the following:
- in cmd: NSSM install LaserX  ->  this opens up the NSSM GUI
- I give the path to executable and launch the service
- service is running successfully (I can see LaserX in the TaskManager under 
Services tab)
- than I try what you suggested:

labview = win32com.client.GetActiveObject("LaserX.Application")

And I get the following error message:


Traceback (most recent call last):
  File "C:/Users/my_user/Documents/Workspace/LaSo/gateway-to-exe.py", line 4, 
in <module>
    labview = win32com.client.GetActiveObject("LaserX.Application") # 
Name-of-activeX-server.Application
  File 
"C:\Users\my_user\AppData\Local\Programs\Python\Python37\lib\site-packages\win32com\client\__init__.py",
 line 79, in GetActiveObject
    dispatch = pythoncom.GetActiveObject(resultCLSID)
pywintypes.com_error: (-2147221021, 'Operation unavailable', None, None)



Am I doing something wrong?  Could you give me an example code or something 
that is proven to be working?  Regards, THunter

________________________________
Feladó: Thomas Pietrowski <thopie...@gmail.com>
Elküldve: 2019. augusztus 27. 13:25
Címzett: Kálózi Zsolt
Másolatot kap: Python-Win32 List
Tárgy: Re: [python-win32] dispatch a background service?

Yes, there is. Dispatch will create a new instance, whereas 
.GetActiveObject(interface name) will give what you want.
So, if you are executing this command but get an error, you know that there is 
no instance running in the back.

Hope that helps
- Thomas

Kálózi Zsolt <zsolt.kal...@eli-alps.hu<mailto:zsolt.kal...@eli-alps.hu>> 
schrieb am Di., 27. Aug. 2019, 12:44:

I would like to ask, if its possible to connect to a windows service somehow 
with pywin32?

I can connect to a running LabView application with 
Dispatch("LabView.Application") without a problem. If I make an executable from 
the LabView app, connecting to it is no problem either.

But the final goal is that .exe to be run as a background service, I used NSSM 
for that.


So The LabView app is now running as an .exe, and it runs constantly as a 
background service when the computer starts. If the LabView runs as a service, 
I'm no longer able to reach it with Dispatch("LabView.Application"). Is there a 
workaround for that problem? How can I connect to a service? Is there like a 
Dispatch("LabView.Service") or something?


Regards,
THunter

________________________________

A jelen email útján megküldött vélemény vagy információ kizárólag a küldő 
személyéhez kapcsolódik és nem feltétlenül jeleníti meg az ELI-HU Nonprofit 
Kft. álláspontját is. Társaságunk nem vállal felelősséget az email tartalmáért, 
ide értve különösen, de nem kizárólagosan kötelezettségvállalást jogi kötő 
erővel bíró szerződések létrehozásáért, módosításáért vagy megszűntetéséért, 
valamint az átadott információ alapján indult eljárásokért mindaddig, amíg az 
adott információt utólag és írásban a megfelelően meghatalmazott vagy az ELI-HU 
Nonprofit Kft. képviseleti jogával felruházott személy meg nem erősíti. Az 
email bizalmas vagy jogilag védett információt tartalmazhat, amelyet kizárólag 
a címzett személy vagy szervezet, illetve az általuk felhatalmazottak 
használhatnak fel. Amennyiben Ön nem az üzenet címzettje, kérjük, értesítse 
erről az üzenet küldőjét és törölje az üzenetet rendszeréből. A jelen email 
tartalmának nem a címzett általi bármilyen formában történő illetéktelen 
közzététele, terjesztése, másolása, illetve felhasználása vagy alkalmazása 
szigorúan tilos és jogszabályba ütközhet.


Please note that any information or opinions presented in this email are solely 
those of the sender and do not necessarily represent those of ELI-HU Nonprofit 
Ltd. Our Company accepts no liability or responsibility for the content of this 
email, especially, but not limited to commitment for establishing, modifying or 
terminating legally binding contracts, or for the consequences of any actions 
taken on the basis of the information provided, unless that information is 
subsequently confirmed in writing by a person duly authorized or endowed with 
the right of representation of ELI-HU Nonprofit Ltd. This email may contain 
confidential or legally protected information, and is intended solely for the 
use of the individual or entity to whom it is addressed and others authorized 
to receive it. If you are not the intended recipient of this email, please 
inform the sender immediately and delete it from your system. Any unauthorized 
disclosure, dissemination, copying or use of or reliance upon the content of 
this email by anyone other than the intended recipient is strictly prohibited 
and may be unlawful.

_______________________________________________
python-win32 mailing list
python-win32@python.org<mailto:python-win32@python.org>
https://mail.python.org/mailman/listinfo/python-win32
________________________________

A jelen email útján megküldött vélemény vagy információ kizárólag a küldő 
személyéhez kapcsolódik és nem feltétlenül jeleníti meg az ELI-HU Nonprofit 
Kft. álláspontját is. Társaságunk nem vállal felelősséget az email tartalmáért, 
ide értve különösen, de nem kizárólagosan kötelezettségvállalást jogi kötő 
erővel bíró szerződések létrehozásáért, módosításáért vagy megszűntetéséért, 
valamint az átadott információ alapján indult eljárásokért mindaddig, amíg az 
adott információt utólag és írásban a megfelelően meghatalmazott vagy az ELI-HU 
Nonprofit Kft. képviseleti jogával felruházott személy meg nem erősíti. Az 
email bizalmas vagy jogilag védett információt tartalmazhat, amelyet kizárólag 
a címzett személy vagy szervezet, illetve az általuk felhatalmazottak 
használhatnak fel. Amennyiben Ön nem az üzenet címzettje, kérjük, értesítse 
erről az üzenet küldőjét és törölje az üzenetet rendszeréből. A jelen email 
tartalmának nem a címzett általi bármilyen formában történő illetéktelen 
közzététele, terjesztése, másolása, illetve felhasználása vagy alkalmazása 
szigorúan tilos és jogszabályba ütközhet.


Please note that any information or opinions presented in this email are solely 
those of the sender and do not necessarily represent those of ELI-HU Nonprofit 
Ltd. Our Company accepts no liability or responsibility for the content of this 
email, especially, but not limited to commitment for establishing, modifying or 
terminating legally binding contracts, or for the consequences of any actions 
taken on the basis of the information provided, unless that information is 
subsequently confirmed in writing by a person duly authorized or endowed with 
the right of representation of ELI-HU Nonprofit Ltd. This email may contain 
confidential or legally protected information, and is intended solely for the 
use of the individual or entity to whom it is addressed and others authorized 
to receive it. If you are not the intended recipient of this email, please 
inform the sender immediately and delete it from your system. Any unauthorized 
disclosure, dissemination, copying or use of or reliance upon the content of 
this email by anyone other than the intended recipient is strictly prohibited 
and may be unlawful.
_______________________________________________
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32

Reply via email to