Python win32服务自动启动
我正在编写一个python win32服务下面是我的代码片段,当我编译它的工作,但我需要去services.msc并手动启动它。
当我安装serivce时有没有选项:myservice.exe install它会自动启动吗?
下面是我的代码片段:
import win32serviceutil
import win32service
import win32event
class SmallestPythonService(win32serviceutil.ServiceFramework):
_svc_name_ = "ser_name"
_svc_display_name_ = "ser_descryption"
#_svc_description_='ddd'
def __init__(self, args):
win32serviceutil.ServiceFramework.__init__(self, args)
self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)
def SvcStop(self):
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
win32event.SetEvent(self.hWaitStop)
def SvcDoRun(self):
win32event.WaitForSingleObject(self.hWaitStop, win32event.INFINITE)
if __name__=='__main__':
win32serviceutil.HandleCommandLine(SmallestPythonService)
没有找到相关结果
已邀请:
4 个回复
淑灯
安装服务并将其设置为自动启动。
细屠截殴些
乐遣杀屎
和
命令。
有关此内容的更多信息,请访问Microsoft KB251192。 win32serviceutil也有一个你可以使用的
功能。
佩疵瓦