failing to install and start windows service with winreg imported

116 Views Asked by At

So I'm building a pretty simple service in python3.6. Client want's it to run on windows, so I'm using the win32serviceutil package to make a windows service. I install and package with pyinstaller and so far everything works great.

The issue I'm having is that the path differs between installing, starting and debugging. When installing and debugging, the path is the same as where I run the command from. When starting the service however, the path is C:/windows/system32

The service needs to boot another .exe so it is important having an absolute path to the bundled application. I solved this by writing the path to registry when installing, and reading when starting the service. I do this using the winreg lib. It works great in debug mode, but it seems the service is run under another user when starting the service normally, and it fails to load somehow. I get Error 1053 : The service did not respond to the start or control request in a timely fashion when running. Importing the winreg lib is fine, but when using it crashes with no error. I'm trying to catch the errors and print but I get nothing on command prompt or the Event Viewer.

Any help appreciated!!

0

There are 0 best solutions below