Windows service fails to start
-
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. -
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. -
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.RoyceF wrote:
...but today I can't get it to start.
If
StartService()
is failing, have you tried callingGetLastError()
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
-
RoyceF wrote:
...but today I can't get it to start.
If
StartService()
is failing, have you tried callingGetLastError()
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
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.
-
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.
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:
-
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:
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.