Reputation: 3772
According to this answer I created a smallest Windows service in Python
.
Then I ran successfully:
python.exe smallest_service.py install
and
python.exe smallest_service.py start
with error message
Starting service SmallestPythonService
Error starting service: The service did not respond to the start or control request in a timely fashion.
My Python version is Python 3.9.6
pip freeze
pypiwin32==223
pywin32 @ file:///C:/Users/me/Downloads/pywin32-301-cp39-cp39-win_amd64.whl
How can I fix it?
Upvotes: 0
Views: 334
Reputation: 892
Here are the list of scenarios one may see -> Error starting service: The service did not respond to the start or control request in a timely fashion.
Missing DLL file: Another instance of the error occurs when you have a missing DLL file on your computer which is used by numerous other applications as well. If this DLL file is in conflict or isn’t present at all, you will experience the error message.
Corrupt/missing system files: Another instance of why this issue occurs is because there are corrupt or missing system files on your computer. If the very installation of Windows is not proper and has issues, you will experience numerous problems including the error message under discussion.
Outdated Windows: Microsoft officially recognized this error message on their official website and even released a temporary hotfix to solve the problem. However, recently they removed the hotfix and instructed users to upgrade to the latest iteration of Windows.
Solutions
The very first thing which we should try is changing the timeout settings of your services through your registry editor. Whenever a service is requested to launch, a timer is started with a predefined value. If the service doesn’t start within this time frame, the error message comes forward reporting so. Here in this solution, we will navigate to your computer’s registry and change the value. If it isn’t present, we will create a new key for it.
-> Press Windows + R, type “regedit” in the dialogue box and press Enter.
Once in the registry editor, navigate to the following file path: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control
-> search for the key of ‘ServicesPipeTimeout’. If you find it already there, you can move to directly edit. However, if you don’t find the entry, select Control, right-click on any space present at the right side of the screen and select New > DWORD -> Name the key as ‘ServicesPipeTimeout’ and set the value as 180000 (You can also right-click the value and click Modify if the option to set the value didn’t come in your case. -> Save changes and exit. Restart your computer completely and then try launching the service. Check if the issue is resolved.
Solution 2: Getting Ownership of the Application
Another rare case that we came across was not having the ownership of the application caused the application not to execute the service properly. This makes sense as if the application doesn’t have enough elevated access, it will not be able to send/read the response to/from a service (especially if it is a system service). In this article, we will navigate to the executable of the application and then change the ownership to our username. If successful, this will solve the problem of getting the error 1053.
Bonus Tip
Making sure .NET Frameworks are in sync: If the application/service which you are trying to launch is on another Framework than that of the hosting machine, you will experience issues. Make sure that the frameworks are in sync.
Upvotes: 1
Reputation:
If that doesn't work for you. It might be interesting to use NSSM. It is an easy piece of code that makes any py file into a windows service.
I've also found that most service creators only work with 32bit Python, so that might also be interesting to look at.
Upvotes: 1