pywin32 icon indicating copy to clipboard operation
pywin32 copied to clipboard

Error with example "serviceEvents.py"

Open krrk opened this issue 7 years ago • 2 comments

I cannot run the Demo pywin32/win32/Demos/service/serviceEvents.py. My setup is Windows 7 x64 with Anaconda 4.4.7, Python 3.6.3, and pywin32 221.

I get the following errors:

python serviceEvents.py start Starting service PyServiceEventDemo Error starting service: The service did not respond to the start or control request in a timely fashion.

python serviceEvents.py debug Debugging service PyServiceEventDemo - press Ctrl+C to stop. Error 0xC000000A - Python could not construct the class instance

<Error getting traceback - traceback.print_exception() failed

(null): (null)

If I put the contents of __init__ in a try-except block and re-raise the exception I get:

python serviceEvents.py debug Debugging service PyServiceEventDemo - press Ctrl+C to stop. Error 0xC000000A - Python could not construct the class instance

Traceback (most recent call last): File "...\pywin32\win32\Demos\service\serviceEvents.py", line 36, in init raise(e) File "...\pywin32\win32\Demos\service\serviceEvents.py", line 34, in init win32con.DEVICE_NOTIFY_SERVICE_HANDLE) pywintypes.error: (1784, 'RegisterDeviceNotification', 'The supplied user buffer is not valid for the requested operation.')

(null): (null)

Any help would be greatly appreciated. This used to work on my system and I don't know what if anything has changed. I have also tried installing other version of pywin32 in a conda environment (218, 219, 220 and 222 (through pip)) to no avail.

krrk avatar Jan 22 '18 21:01 krrk

Did you try running the .exe installer? I suspect that the pywin32_postinstall.py script hasn't been run in an elevated environment, which the .exe installer will do automatically.

mhammond avatar Jan 23 '18 02:01 mhammond

The service starts for me, but I also can't debug

Python 3.9.13 pywin32 306-308 (wheel from PyPI) Windows 10.0.19045 Build 19045 Running powershell as admin

PS > python serviceEvents.py install
Installing service PyServiceEventDemo
copying host exe 'C:\Program Files\Python39\lib\site-packages\win32\pythonservice.exe' -> 'C:\Program Files\Python39\pythonservice.exe'
copying helper dll 'C:\Program Files\Python39\lib\site-packages\pywin32_system32\pywintypes39.dll' -> 'C:\Program Files\Python39\pywintypes39.dll'
Service installed
PS > python serviceEvents.py start
Starting service PyServiceEventDemo
PS > python serviceEvents.py debug
Debugging service PyServiceEventDemo - press Ctrl+C to stop.
Error 0xC000000A - Python could not construct the class instance

<Error getting traceback - traceback.print_exception() failed>

(null): (null)

Edit: This seems to happen in the pythonservice.exe file: &"C:/Program Files/Python39/pythonservice.exe" -debug PyServiceEventDemo (which is ultimately called by the python code for my installation) is the command that fails.

Avasam avatar Jun 05 '24 17:06 Avasam