Fixed a problem where Windows services written in python could not be started

  • 2020-04-02 13:33:07
  • OfStack

"The service did not respond or control the request in time" error, use pyinstaller generation is not; After checking the data, modify setup.py as follows, please replace the service name and script name by yourself:


#!/usr/bin/python  
#-*-coding:cp936-*-
from distutils.core import setup
import py2exe
class Target:
    def __init__(self, **kw):
        self.__dict__.update(kw)
        # for the versioninfo resources
        self.version = "1.1.8"
        self.company_name = "Yovole Shanghai Co. Ltd."
        self.copyright = "Copyright (c) 2013 Founder Software (Shanghai) Co., Ltd. "
        self.name = "Guest Agent"

myservice = Target(
    description = 'Yovole Cloud Desktop Guest Agent',
    modules = ['service'],
    cmdline_style='pywin32'
    #icon_resources=[(1, "cartrigde.ico")] 
)
options = {"py2exe":   
            {   "compressed": 1,   
                "bundle_files": 1 
            }   
          }  

setup(
    service=[myservice],
    options = options, 
    zipfile = None,
    windows=[{"script": "service.py"}], 
)

 


Related articles: