Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Windows service fails to start

Windows service fails to start

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionwindows-admindebugging
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RoyceF
    wrote on last edited by
    #1

    Hi, I have a Windows service that I had running yesterday, but today I can't get it to start. I have gone back to my old code that ran yesterday, but it still doesn't start. How can I get an error code that will give me some hint of what the problem is? The failing code is shown below: if( ::StartService(schService, 0, 0) ) { Sleep(1000); while( ::QueryServiceStatus(schService, &m_ssStatus) ) { if( m_ssStatus.dwCurrentState == SERVICE_START_PENDING ) { TRACE( "." ); **THIS LOOP NEVER EXITS, SO I CAN'T GET AN ERROR CODE** Sleep( 1000 ); } else break; } I found an event in the application event log with the following description, but I don't know what it means: The description for Event ID ( 0 ) in Source ( AutoFileHandler ) 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: Service installed. Can anybody help me with this? Any help greatly appreciated.

    L D 2 Replies Last reply
    0
    • R RoyceF

      Hi, I have a Windows service that I had running yesterday, but today I can't get it to start. I have gone back to my old code that ran yesterday, but it still doesn't start. How can I get an error code that will give me some hint of what the problem is? The failing code is shown below: if( ::StartService(schService, 0, 0) ) { Sleep(1000); while( ::QueryServiceStatus(schService, &m_ssStatus) ) { if( m_ssStatus.dwCurrentState == SERVICE_START_PENDING ) { TRACE( "." ); **THIS LOOP NEVER EXITS, SO I CAN'T GET AN ERROR CODE** Sleep( 1000 ); } else break; } I found an event in the application event log with the following description, but I don't know what it means: The description for Event ID ( 0 ) in Source ( AutoFileHandler ) 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: Service installed. Can anybody help me with this? Any help greatly appreciated.

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      What happens whey try to start the service using the Standard Windows Services MMC snap in?

      led mike

      1 Reply Last reply
      0
      • R RoyceF

        Hi, I have a Windows service that I had running yesterday, but today I can't get it to start. I have gone back to my old code that ran yesterday, but it still doesn't start. How can I get an error code that will give me some hint of what the problem is? The failing code is shown below: if( ::StartService(schService, 0, 0) ) { Sleep(1000); while( ::QueryServiceStatus(schService, &m_ssStatus) ) { if( m_ssStatus.dwCurrentState == SERVICE_START_PENDING ) { TRACE( "." ); **THIS LOOP NEVER EXITS, SO I CAN'T GET AN ERROR CODE** Sleep( 1000 ); } else break; } I found an event in the application event log with the following description, but I don't know what it means: The description for Event ID ( 0 ) in Source ( AutoFileHandler ) 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: Service installed. Can anybody help me with this? Any help greatly appreciated.

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        RoyceF wrote:

        ...but today I can't get it to start.

        If StartService() is failing, have you tried calling GetLastError() to find out why?

        "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

        "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

        R 1 Reply Last reply
        0
        • D David Crow

          RoyceF wrote:

          ...but today I can't get it to start.

          If StartService() is failing, have you tried calling GetLastError() to find out why?

          "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

          "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

          R Offline
          R Offline
          RoyceF
          wrote on last edited by
          #4

          When I try to start it from the services panel, it just hangs for 2 or 3 minutes before the system shows a dialog indicating that the service failed to start. StartService() doesn't fail, nor does QueryServiceStatus(). QueryServiceStatus() puts zeros in the exit code variables dwWin32ExitCode and dwServiceSpecificExitCode of the SERVICE_STATUS struct. It just never exits the loop waiting for the m_ssStatus.dwCurrentState to change from SERVICE_START_PENDING. GetLastError() always returns 0.

          M 1 Reply Last reply
          0
          • R RoyceF

            When I try to start it from the services panel, it just hangs for 2 or 3 minutes before the system shows a dialog indicating that the service failed to start. StartService() doesn't fail, nor does QueryServiceStatus(). QueryServiceStatus() puts zeros in the exit code variables dwWin32ExitCode and dwServiceSpecificExitCode of the SERVICE_STATUS struct. It just never exits the loop waiting for the m_ssStatus.dwCurrentState to change from SERVICE_START_PENDING. GetLastError() always returns 0.

            M Offline
            M Offline
            Mark Salsbery
            wrote on last edited by
            #5

            RoyceF wrote:

            it just hangs for 2 or 3 minutes

            Are you sure your service application is starting correctly (particularly, SetServiceStatus() to SERVICE_RUNNING)? Have you tried attaching to the service process with the debugger to see what's going on? Mark

            Mark Salsbery Microsoft MVP - Visual C++ :java:

            R 1 Reply Last reply
            0
            • M Mark Salsbery

              RoyceF wrote:

              it just hangs for 2 or 3 minutes

              Are you sure your service application is starting correctly (particularly, SetServiceStatus() to SERVICE_RUNNING)? Have you tried attaching to the service process with the debugger to see what's going on? Mark

              Mark Salsbery Microsoft MVP - Visual C++ :java:

              R Offline
              R Offline
              RoyceF
              wrote on last edited by
              #6

              Yes, I have tried starting the service from the services snapin, then attaching the debugger. It is always stuck in this loop waiting for a change in the current state. I have also stepped into the code from the Winmain entrance and it goes directly to this wait loop. However, I will have to wait until Monday as I can't uninstall the service remotely in order to restart it and I am not at my workstation. So I will pursue this then. Thanks for your help.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups