I am using Windows XP(everything works fine on Vista), Python version 2.6 and Py2exe version 0.6.9. I am attempting to build a service to restart an existing program(OpenVPN service) when it loses connectivity for an extended period of time. I Have combined my own work with a pre-existing sample provided on the web. The py file installs the service and works flawlessly. The py seems to turn into an executable just fine and does it duty just fine but,  when I install and run the service the event log does not give the proper information.  The event log errors are “The description for Event ID ( 4098 ) in Source ( OpenVPNTestConnectService ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. You may be able to use the /AUXSOURCE= flag to retrieve this description; see Help and Support for details. The following information is part of the event: OpenVPNTestConnectService.exe, .

And

The description for Event ID ( 255 ) in Source ( OpenVPNTestConnectService ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. You may be able to use the /AUXSOURCE= flag to retrieve this description; see Help and Support for details. The following information is part of the event: Open VPN Test Connection Service - STOPPED.

 

The issue I am trying to fix is ” ( OpenVPNTestConnectService ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. You may be able to use the /AUXSOURCE= flag to retrieve this description; see Help and Support for details. The following information is part of the event:”

 

My setup. Py is:

from distutils.core import setup

import py2exe

setup(service=["OpenVPNTestConnectService"],

      options={"py2exe":{"excludes":["Tkconstants","Tkinter","tcl",

                                     "_imagingtk","PIL._imagingtk",

                                     "ImageTk", "PIL.ImageTk",

                                     "FixTk"],

                         "compressed": 1,

                         "ascii": 1,

                         "bundle_files":2}}

      )

 

 

My Service file is:

'''

OpenVPNTestConnectService.py

 Author: Alex Baker

 Date: 7th July 2008

 Description : Simple python program to generate wrap as a service based on example on the web, see link below.

 

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

 

 Usage : python aservice.py install

 Usage : python aservice.py start

 Usage : python aservice.py stop

 Usage : python aservice.py remove

 

 C:\>python aservice.py  --username <username> --password <PASSWORD> --startup auto install

 

'''

#import TestOpenVPN

from time import sleep, localtime

from subprocess import Popen, PIPE

from string import count

import win32service

import win32serviceutil

import win32api

import win32con

import win32event

import win32evtlogutil

import os

import servicemanager

 

class OpenVPNTestConnectService(win32serviceutil.ServiceFramework):

  

   _svc_name_ = "OpenVPNTestConnectService"

   _svc_display_name_ = "Open VPN Test Connection Service"

   _svc_description_ = "Test OpenVPN Connectivity"

         

   def __init__(self, args):

         win32serviceutil.ServiceFramework.__init__(self, args)

         self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)

         reg = win32evtlogutil

         #reg.AddSourceToRegistry("OpenVPNTestConnectService",None,"Application",None)

         win32evtlogutil.AddSourceToRegistry("OpenVPNTestConnectService", "OpenVPNTestConnectService.exe")

         self.network_manager = 4

         self.ping_Answer=1

         self.ServiceCheck = "OpenVPNTestConnectService"

         self.Service2Restart = "openvpnservice"

   def SvcStop(self):

           self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)

           win32event.SetEvent(self.hWaitStop)                   

        

   def SvcDoRun(self):

      import servicemanager

      win32evtlogutil.AddSourceToRegistry("OpenVPNTestConnectService", "OpenVPNTestConnectService.exe")

      win32evtlogutil.ReportEvent(self._svc_name_,servicemanager.PYS_SERVICE_STARTED,0,servicemanager.EVENTLOG_INFORMATION_TYPE,(self._svc_name_, ''))

      servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE,servicemanager.PYS_SERVICE_STARTED,('OpenVPNTestConnectService.exe', ''))    

      self.timeout = 4000

      self.restartOpenVPN = 0

 

      while 1:

         # Wait for service stop signal, if I timeout, loop again

         rc = win32event.WaitForSingleObject(self.hWaitStop, self.timeout)

         # Check to see if self.hWaitStop happened

         if rc == win32event.WAIT_OBJECT_0:

            # Stop signal encountered

            servicemanager.LogInfoMsg("Open VPN Test Connection Service - STOPPED")

            break

         else: 

            #test = TestOpenVPN.TestOpenVPN()

            self.restartOpenVPN = self.Start_Test("vpnsrvtest.dcp.alb.edu")

            if self.restartOpenVPN == 0:

               servicemanager.LogInfoMsg("Open VPN Test Connection Service - Started")

            if self.restartOpenVPN == 1:

               servicemanager.LogInfoMsg("Open VPN Test Connection Service - Started the OpenVPN Service")

            if self.restartOpenVPN == 2:

               servicemanager.LogInfoMsg("Open VPN Test Connection Service - Restarted the OpenVPN Service")

   def Start_Test(self,computerName):

        self.server2Ping = "ping %s -n 1" % computerName

        while self.ping_Answer == 1 and self.network_manager == 4:

            self.network_manager = win32serviceutil.QueryServiceStatus(self.ServiceCheck)

            self.network_manager = self.network_manager[1]

            sleep(1)

            self.ping_Answer = self.ping()

       

        if self.ping_Answer == 0 and self.network_manager == 4:

            self.network_manager = win32serviceutil.QueryServiceStatus(self.ServiceCheck)

            self.network_manager = self.network_manager[1]

            startedService = self.restart_service(self.Service2Restart)

            return startedService

            sleep(2)

            self.ping_Answer = self.ping()

        else:

            sleep(1)

   def ping(self):

        ping_number = 0

        ping_results = 0

        while ping_number != 20 and self.network_manager == 4:

            pinging = Popen(self.server2Ping, shell=True, stdout=PIPE)

            stdout = pinging.communicate()

            stdout = str(stdout)

            test_string = count(stdout,'Received = 1')

            ping_number = ping_number + 1

            if test_string == 1:

                ping_results =  ping_results + 1

            self.network_manager = win32serviceutil.QueryServiceStatus(self.ServiceCheck)

            self.network_manager = self.network_manager[1]

            sleep(1)

        if  ping_results < 10:

            return 0

        else:

            return 1

   def restart_service(self, service):

        sleep(1)

        self.network_manager = 4

        restart_minute = 0

        openvpnService = win32serviceutil.QueryServiceStatus(self.Service2Restart)

        openvpnService = openvpnService[1]

        if openvpnService != 4:

            startservice = win32serviceutil

            startservice.StartService(self.Service2Restart)

            sleep(1)

            return 1

        else:

            stopservice = win32serviceutil

            stopservice.StopService(self.Service2Restart)

            current_time = localtime()

            hour = current_time.tm_hour

            minute = current_time.tm_min

            second = current_time.tm_sec

            if minute <= 57:

                start_minute = minute + 2

                start_second = second

                start_hour = hour

            elif minute == 58 and hour != 23:

                start_minute = 00

                start_hour = hour + 1

                start_second = second

            elif minute == 58 and hour == 23:

                start_minute = 00

                start_hour = 00

                start_second = second

            elif minute == 59 and hour != 23:

                start_minute = 01

                start_hour = hour + 1

                start_second = second

            elif minute == 59 and hour == 23:

                start_minute = 01

                start_hour = 00

                start_second = second

            while start_minute != restart_minute and self.network_manager == 4:

                current_time = localtime()

                restart_minute = current_time.tm_min

                self.network_manager = win32serviceutil.QueryServiceStatus(self.ServiceCheck)

                self.network_manager = self.network_manager[1]

                sleep(2)

            startservice = win32serviceutil

            startservice.StartService(self.Service2Restart)

            return 2

            sleep(1)

def ctrlHandler(ctrlType):

   return True

                 

if __name__ == '__main__':  

   win32api.SetConsoleCtrlHandler(ctrlHandler, True)  

   win32serviceutil.HandleCommandLine(OpenVPNTestConnectService)

 

Any help would be greatly appreciated.