Windows Service Not Starting on W2K

My service seems to work fine on XPPro, but not on W2K Server.

I have a Windows Service I created that just sets a timer and writes to
EventLog every 10 seconds.

It installed fine and it actually starts.  But it says it doesn't.  The
progress bar shows the progress fine until it hits about halfway.  It then
stops there for about 4 or 5 seconds then goes a little farther.  I then get
a message:

Could not start the MyService Service on Local Computer.
Error 1053: The service did not respond to the Start or control request in a
timely fashion.

I look at the MyService log from Event Viewer and it is running and writing
to the Event log every 10 seconds, as it should.

But in the Services screen, it shows MyService as starting (not started) and
I can't stop it

If I try to stop it from Task Manager, I get the message:

The operation could not be completed.
Access is denied.

I have to reboot to stop it.

Here is the code:

****************************************************************************
*****
Imports System.ServiceProcess

Public Class Service1
    Inherits System.ServiceProcess.ServiceBase

#Region " Component Designer generated code "

    Public Sub New()
        MyBase.New()

        ' This call is required by the Component Designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call

    End Sub

    'UserService overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    ' The main entry point for the process
    <MTAThread()> _
    Shared Sub Main()
        Dim ServicesToRun() As System.ServiceProcess.ServiceBase

        ' More than one NT Service may run within the same process. To add
        ' another service to this process, change the following line to
        ' create a second service object. For example,
        '
        '   ServicesToRun = New System.ServiceProcess.ServiceBase () {New
Service1, New MySecondUserService}
        '
        ServicesToRun = New System.ServiceProcess.ServiceBase () {New
Service1}

        System.ServiceProcess.ServiceBase.Run(ServicesToRun)
    End Sub

    'Required by the Component Designer
    Private components As System.ComponentModel.IContainer

    ' NOTE: The following procedure is required by the Component Designer
    ' It can be modified using the Component Designer.
    ' Do not modify it using the code editor.
    Friend WithEvents Timer1 As System.Timers.Timer
    <System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
        Me.Timer1 = New System.Timers.Timer()
        CType(Me.Timer1,
System.ComponentModel.ISupportInitialize).BeginInit()
        '
        'Timer1
        '
        Me.Timer1.Enabled = True
        Me.Timer1.Interval = 10000
        '
        'Service1
        '
        Me.ServiceName = "Service1"
        CType(Me.Timer1, System.ComponentModel.ISupportInitialize).EndInit()

    End Sub

#End Region

    Protected Overrides Sub OnStart(ByVal args() As String)
        ' Add code here to start your service. This method should set things
        ' in motion so your service can do its work.
        Timer1.Enabled = True
    End Sub

    Protected Overrides Sub OnStop()
        ' Add code here to perform any tear-down necessary to stop your
service.
        Timer1.Enabled = False
    End Sub

    Private Sub Timer1_Elapsed(ByVal sender As System.Object, ByVal e As
System.Timers.ElapsedEventArgs) Handles Timer1.Elapsed
        Dim MyLog As New EventLog()

        '  Check if the Event Log exists
        If Not MyLog.SourceExists("MyService") Then
            MyLog.CreateEventSource("MyService", "Myservice Log") ' Create
Log
        End If
        MyLog.Source = "MyService"
        ' Write to the Log
        MyLog.WriteEntry("MyService Log", "This is log on " &
CStr(TimeOfDay), EventLogEntryType.Information)
    End Sub
End Class
****************************************************************************
*****

Why isn't it working correctly

This program isn't doing much and it seems to be working fine, except for
the starting/stopping parts.

Thanks,

Tom



Answer this question

Windows Service Not Starting on W2K

  • taze

    I believe this error (Error 1053: The service did not respond to the Start or control request in a
    timely fashion.) can come up when the service does not have the proper privileges (A quick web search on the error number shows it could be a number of other issues as well), a check is are you running as admin on the win2k server machine  

     


  • Andrew Cowan

    My logon is in the administrator group.

    Would that be what I would be looking for

    Thanks,

    Tom


  • David Maynard

    Yes, if you are in the administrator group and running the service from that account you should have full priviledges, there must be some other issue that is causing this.  What service pack are you running on   It seems like there are some changes to the System State in between SPs.

    http://www.faqshop.com/misc/default.htm http://www.faqshop.com/misc/bits/err%2053.htm

    If this doesn't help, please post back again.


  • Windows Service Not Starting on W2K