Frage

In eine andere Frage Ich gestern gepostet habe, bekam ich sehr gute Ratschläge, wie man ein Python-Skript ausgeführt werden könnte als Dienst in Windows.Was ich bin Links Fragen, ist:Wie ist Windows Kenntnis von den Dienstleistungen, die verwaltet werden können in der nativen tools (die"Dienste" Fenster "Verwaltung").I.e.was ist die Windows-Entsprechung der Umsetzung einer start - /stop-Skript in /etc/init.d unter Linux?

War es hilfreich?

Lösung

Wie bei den meisten "bewusst" die Dinge in Windows, die Antwort ist "Registrierung".

Werfen Sie einen Blick auf diesen Artikel der Microsoft Knowledge Base: http://support.microsoft.com/kb/103000

Suche für "Ein Win32-Programm, dass gestartet werden kann durch die Service-Controller und gehorcht der service-control-protocol". Dies ist die Art von Dienstleistung, die Sie interessiert.

Die service-Registrierung (Inhalte KEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services \myservice) trägt Informationen über den service, einschließlich Dinge wie die ausführbare Ort, was zu tun ist, wenn es fehlschlägt (halt das OS?), welche Dienste müssen gestartet werden, bevor diese ein, welche Benutzer es ausgeführt wird.

Wie zu service control protocol, main() des Programms soll zum aufrufen einer Windows-API-Aufruf, einrichten Rückrufe für start, stop, pause für Ihre service.Was Sie tun in diesen Rückrufen ist alle bis zu Sie.

Andere Tipps

Hier ist der code, installieren Sie einen python-Skript als Dienst, geschrieben in python :)

http://code.activestate.com/recipes/551780/

Dieser Beitrag könnte Ihnen auch helfen:

http://essiene.blogspot.com/2005/04/python-windows-services.html

Don ' T muck mit der Registrierung direkt zu.Benutzer der SC command-line tool.Nämlich, ERSTELLEN Sie 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

Sie können verwenden srvany.exe von Windows NT Resource Kit, um erstellen Sie einen benutzerdefinierten Dienst in der admin tools...

http://support.microsoft.com/kb/137890

Ich bin mit dieser Methode zu führen tracd (ein python-script / server) für trac.

Hier sind einige sehr klare Anweisungen: http://www.tacktech.com/display.cfm?ttid=197

Es erfordert einige registry-Bearbeitung (sehr minimal und einfach, aber können Sie machen, jede Kommandozeile / script windows-Dienst.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top