Python win32 service starting automatically

I am writing a python win32 service below are snippet of my code when i compile the service it works but i need to go to services.msc and start it manually.

Is there an option when i install the serivce by : myservice.exe install it will starts automaticly ?

below are snippet of my code :

import win32serviceutil
import win32service
import win32event

class SmallestPythonService(win32serviceutil.ServiceFramework):
   _svc_name_ = "ser_name"
   _svc_display_name_ = "ser_descryption"
   def __init__(self, args):

      win32serviceutil.ServiceFramework.__init__(self, args)
                    self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)

    def SvcStop(self):


   def SvcDoRun(self):

       win32event.WaitForSingleObject(self.hWaitStop, win32event.INFINITE)

if __name__=='__main__':


Use myservice.exe --startup=auto install to install the service and set it to be started automatically.

Leave a Comment