我怎么做Windows知道的服务,我已经写在蟒蛇?
-
09-06-2019 - |
题
在 另一个问题 我昨天,我有非常好的建议就如何Python脚本可以作为一个服务窗口。我想是:怎么是Windows知道的服务,以管理当地的工具("服务"窗口"的行政工具")。I.e.什么是Windows相当把启动/停止的脚本中/etc/init。d在Linux?
解决方案
如同大多数"知道"的东西,在Windows,答案是"注册".
看看这个Microsoft的知识基础的文章: http://support.microsoft.com/kb/103000
搜索"一Win32程序,可以通过服务器和服从业务控制协议。" 这是什么样的服务你感兴趣。
服务登记(内容KEY_LOCAL_MACHINE系统\CurrentControlSet\服务 \myservice)携带的信息有关的服务,包括像其可执行的位置,什么做的时候,它的失败(停止操作系统?), 什么样的服务必须开始之前,这一个,是什么用户运行为。
作为对服务的控制协议,主要()您的节目是应该调用Windows API调,设立回调,开始、停止、暂停为您服务。你做什么在那些回调的是一切都取决于你。
其他提示
这里是代码,以安装一个python-脚本作为一个服务,编写python:)
http://code.activestate.com/recipes/551780/
这个职位还可以帮助你出:
http://essiene.blogspot.com/2005/04/python-windows-services.html
不淤泥与登记册。用户SC命令行工具。即SC创建
DESCRIPTION: SC is a command line program used for communicating with the NT Service Controller and services. USAGE: sc [command] [service name] ... The option has the form "\\ServerName" Further help on commands can be obtained by typing: "sc [command]" Commands: query-----------Queries the status for a service, or enumerates the status for types of services. queryex---------Queries the extended status for a service, or enumerates the status for types of services. start-----------Starts a service. pause-----------Sends a PAUSE control request to a service. interrogate-----Sends an INTERROGATE control request to a service. continue--------Sends a CONTINUE control request to a service. stop------------Sends a STOP request to a service. config----------Changes the configuration of a service (persistant). description-----Changes the description of a service. failure---------Changes the actions taken by a service upon failure. qc--------------Queries the configuration information for a service. qdescription----Queries the description for a service. qfailure--------Queries the actions taken by a service upon failure. delete----------Deletes a service (from the registry). create----------Creates a service. (adds it to the registry). control---------Sends a control to a service. sdshow----------Displays a service's security descriptor. sdset-----------Sets a service's security descriptor. GetDisplayName--Gets the DisplayName for a service. GetKeyName------Gets the ServiceKeyName for a service. EnumDepend------Enumerates Service Dependencies. The following commands don't require a service name: sc boot------------(ok | bad) Indicates whether the last boot should be saved as the last-known-good boot configuration Lock------------Locks the Service Database QueryLock-------Queries the LockStatus for the SCManager Database EXAMPLE: sc start MyService
你可以使用srvany.exe 从Windows NT资源工具包,以创建一个用户定义的服务,将显示在管理工具...
http://support.microsoft.com/kb/137890
我用这个方法的运行tracd(python脚本/服务器),用于核心预算资源调拨目标(trac).
这里有一些很清楚的说明: http://www.tacktech.com/display.cfm?ttid=197
它不会需要一些注册编辑(很小的和易),但会让你做任何命令行/脚本的windows服务。