Protected Overrides Sub OnStart(ByVal toArgs As String()) oRobot.oWindowsService = Me ' If we cannot start If Not oRobot.Start() Then lStart = False ' If this from the Console application If Environment.UserInteractive Then Exit Sub End If End If Dim acceptedCommandsFieldInfo As System.Reflection.FieldInfo = GetType(ServiceBase).GetField("acceptedCommands", _ System.Reflection.BindingFlags.Instance Or System.Reflection.BindingFlags.NonPublic) If acceptedCommandsFieldInfo Is Nothing Then 'Throw ApplicationException("acceptedCommands field not found") End If Dim value As Integer = CInt(acceptedCommandsFieldInfo.GetValue(Me)) acceptedCommandsFieldInfo.SetValue(Me, value Or SERVICE_ACCEPT_PRESHUTDOWN) ' Define the timer AddHandler oTimer.Elapsed, AddressOf ServiceTimer ' Start the timer oTimer.Enabled = True End Sub