Article ID: 320789 - View products that this article applies to.
This article was previously published under Q320789
If a service is not written correctly, the Service Control Manager (SCM) may log the following error in the system event log when you use the net start command to start the service:
However, this error message may not be generated if the Services tool in Control Panel (on a Windows NT 4.0-based system) or the Microsoft Management Console (MMC) Services snap-in (on a Windows 2000 or Windows XP-based system) is used to start the service.
Event ID: 7016
Source: Service Control Manager
Description: The ServiceName service has reported an invalid current state 0.
After you use the net start command to start the service, Net.exe interrogates the service by calling the ControlService function with a SERVICE_CONTROL_INTERROGATE control code until the service reports a status of SERVICE_RUNNING or SERVICE_STOPPED. If the service control handler of the corresponding service calls SetServiceStatus with an invalid value for dwCurrentState, the SCM reports the aforementioned error in the system event log.
To resolve this issue, the service must be fixed (rewritten correctly) so that it reports a valid status when it receives a SERVICE_CONTROL_INTERROGATE (or any other) control code from the SCM.
If the Services tool in Control Panel (on a Windows NT 4.0-based system) or the MMC Services snap-in (on a Windows 2000 or Windows XP-based system) is used to start the service, the QueryServiceStatus function is used to track the progress of the service until it reports a status of SERVICE_RUNNING or SERVICE_STOPPED. QueryServiceStatus returns the most recent status information reported to the SCM. The SCM does not call the service control handler in this scenario.
However, Net.exe determines the current service status by interrogating the service periodically by using the ControlService function with a SERVICE_CONTROL_INTERROGATE control code. This control code is delivered to the control handler for the service. In response, the service posts its current status information back to the SCM by calling SetServiceStatus. The service control handler code should report one of the following valid states, which are defined in the winsvc.h header file:
If a service state not listed in the preceding code sample is reported by the service, the SCM will log an error with Event ID 7016 in the system event log, together with the name of the service.
These same symptoms may occur if any other application interrogates the service to determine its current status.
For additional information, click the article numbers below to view the articles in the Microsoft Knowledge Base:
(http://support.microsoft.com/kb/257509/EN-US/ )Hardware Inventory May Cause Third-Party Win32 Services to Stop
(http://support.microsoft.com/kb/257689/EN-US/ )Error Message When You Use "Net" Command with Microsoft Exchange Connector for POP3 Mailboxes
Article ID: 320789 - Last Review: November 21, 2006 - Revision: 5.1