[python-win32] win32com.client.WithEvents fails when running as a Windows service

Tim Roberts timr at probo.com
Sat Mar 6 21:07:59 EST 2021


On Mar 6, 2021, at 6:43 AM, Marius Cirsta <mforce2 at gmail.com> wrote:
> 
>  I'm trying to automate CANoe using win32com. I've written a script that works perfectly when I log in and run it as a normal user.
> ...
> When being run as a service though I get this error:
> 
> Traceback (most recent call last):
>   File "D:\Jenkins\Scripts\dispatch.py", line 203, in <module>
>     exec_test(PDConfigPath, "CommonTests", "PD_CSB")
>   File "D:\Jenkins\Scripts\dispatch.py", line 146, in exec_test
>     win32com.client.WithEvents(csbTstMod, TestModuleEvents)
>   File "C:\Program Files\Python39\lib\site-packages\win32com\client\__init__.py", line 336, in WithEvents
>     instance = result_class(disp) # This only calls the first base class __init__.
>   File "C:\WINDOWS\TEMP\gen_py\3.9\7F31DEB0-5BCC-11D3-8562-00105A3E017Bx0x1x58.py", line 19507, in __init__
>     cookie=cp.Advise(win32com.server.util.wrap(self, usePolicy=EventHandlerPolicy))
> pywintypes.com_error: (-2147024891, 'Access is denied.', None, None)

Do you have your service configured to run as your user?  The normal service user has different access permissions, so it can’t access your file shares.
— 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/python-win32/attachments/20210306/525dee17/attachment.html>


More information about the python-win32 mailing list