python 服务注册_python注册Windows服务

本文介绍了如何使用Python的pywin32库创建一个Windows服务,并提供了详细的服务注册、更新、查看和停止操作的步骤。示例代码展示了一个每5秒在C盘创建文件的服务。
摘要由CSDN通过智能技术生成

注册windows服务程序框架

安装pywin32

pip install pywin32

按照下述程序框架编写代码,业务逻辑写main函数里即可。

'''

SMWinservice

by Davide Mastromatteo

Base class to create winservice in Python

-----------------------------------------

Instructions:

1. Just create a new class that inherits from this base class

2. Define into the new class the variables

_svc_name_ = "nameOfWinservice"

_svc_display_name_ = "name of the Winservice that will be displayed in scm"

_svc_description_ = "description of the Winservice that will be displayed in scm"

3. Override the three main methods:

def start(self) : if you need to do something at the service initialization.

A good idea is to put here the inizialization of the running condition

def stop(self) : if you need to do something just before

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值