Example of a Windows service implemented in Python
The service should be built in a Python environment that includes the
pywin32
and pyinstaller
packages. Note that as of this writing
(2016-03-37), PyInstaller supports Python versions only through 3.5.
The command for building the service is:
pyinstaller example_service.spec
and should be issued from the root repo directory. PyInstaller will
place the built service in the directory build\example_service
.
To install and start the service, issue the commands:
example_service.exe install
example_service.exe start
from the build\example_service
directory. Note that the commands
must be issued from a command prompt that was run as administrator.
To stop and remove the service, issue the commands:
example_service.exe stop
example_service.exe remove
As above, the commands must be issued from the build\example_service
directory and from an administrator command prompt.