Reboot windows when nobody logged in

Lukas Kubin kubin at opf.slu.cz
Mon Feb 17 07:39:48 EST 2003


Yes, the service runs automatically at startup under the "Local System"
account. If it helps, I'll place
the code below:
Thank you.

lukas

# file: service.py

import win32serviceutil
import win32service
from logserver import * # this is my code
import sys

class ObnovaService(win32serviceutil.ServiceFramework):
    _svc_name_ = "PyObnovaService"
    _svc_display_name_ = "Python Obnova Service"
    server = SocketServer.TCPServer(('', 6378), ObnovaLogserver)

    def __init__(self, args):
        win32serviceutil.ServiceFramework.__init__(self, args)

    def SvcStop(self):
        self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)

    def SvcDoRun(self):
        import servicemanager
        servicemanager.LogMsg(
        servicemanager.EVENTLOG_INFORMATION_TYPE,
        servicemanager.PYS_SERVICE_STARTED,
        (self._svc_name_, ''))

        self.server.handle_request()

if __name__ == '__main__':
    win32serviceutil.HandleCommandLine(ObnovaService)

# file: logserver.py

import sys
import SocketServer
import restart # I used the example by Mark Hammond

class ObnovaLogserver(SocketServer.StreamRequestHandler):

        def handle(self):
                import string
                self.on_start()
                input = self.rfile.readline(10)
                self.process_input(input.strip())
                self.on_stop()

        def process_input(self, input):
                restart.RebootServer()





More information about the Python-list mailing list