- Oct 16, 2019 Service triggers were introduced in Windows 7 and Server 2008 R2. And here is the point of this journey into triggers: A service that has at least one trigger will show up with the 'Trigger Start' designation in the Services application. (Note that the treatment of triggers in the Services application stops there.
- Trigger start services have a 'TriggerInfo' key under their registry key with one or more triggers defined beginning with '0'. The 'DNS Client' service is one of these 'Trigger Start' services on Windows 10: The simplest way to check for the existence of a registry key is with the Test-Path cmdlet.
- The Trigger Start Services concept is brand new in Windows 7. You are probably already familiar with Windows Services, but the trigger start services behave differently than the other regular windows services, as they are not running all the time, rather they run as the result of any trigger.
This article provides workarounds for an issue where the Windows Time service doesn't automatically start in a stand-alone environment.
Numerical value to indicate if the service startup type has: 0 - no startup triggers 1 - has startup triggers This macro is supported since Zabbix 3.4.4. It is useful to discover such service startup types as Automatic (trigger start), Automatic delayed (trigger start) and Manual (trigger start). Service Triggers (aka Trigger-Start Services) allow services to be started and stopped when certain conditions are met. Triggers can be managed with the venerable SC command-line utility, already used to control windows services. This page presents the trigger-related syntax of the SC command.
Original product version: Windows 7 Service Pack 1, Windows Server 2012 R2
Original KB number: 2385818
Symptoms
On a workgroup computer that's running Windows 7, Windows Server 2008 R2, or a later version of Windows, the Windows Time service stops immediately after system startup. This issue occurs even after the Startup Type is changed from Manual to Automatic.
Cause
This issue occurs because the Windows Time service is configured as the Trigger-Start service, and this has been implemented as the default setting in Windows 7 and Windows Server 2008 R2.
Services and background processes have a significant effect on the performance of the system. The Trigger-Start service has been implemented in Windows 7 and Windows Service 2008 R2 in order to reduce the total number of auto-start services on the system. The goal is to improve the stability of the whole system, and this includes improving performance and reducing power consumption. Under this implementation, the Service Control Manager has been enhanced to handle starting and stopping services by using specific system events.
For more information, see Service trigger events.
Whether or not the Windows Time service starts automatically depends on whether the computer is joined to an Active Directory Domain Services (AD DS) domain environment or is configured as a workgroup computer. The Windows Time service on domain-joined computers starts when a trigger event occurs. On workgroup computers that are not joined to an AD DS domain, the startup value for the Windows Time service is Manual, and the service status is Stopped.
You can check the Trigger-Start service settings by running the following sc qtriggerinfo
command:
This issue occurs because the Windows Time service is configured as the Trigger-Start service, and this has been implemented as the default setting in Windows 7 and Windows Server 2008 R2.
Services and background processes have a significant effect on the performance of the system. The Trigger-Start service has been implemented in Windows 7 and Windows Service 2008 R2 in order to reduce the total number of auto-start services on the system. The goal is to improve the stability of the whole system, and this includes improving performance and reducing power consumption. Under this implementation, the Service Control Manager has been enhanced to handle starting and stopping services by using specific system events.
For more information, see Service trigger events.
Whether or not the Windows Time service starts automatically depends on whether the computer is joined to an Active Directory Domain Services (AD DS) domain environment or is configured as a workgroup computer. The Windows Time service on domain-joined computers starts when a trigger event occurs. On workgroup computers that are not joined to an AD DS domain, the startup value for the Windows Time service is Manual, and the service status is Stopped.
You can check the Trigger-Start service settings by running the following sc qtriggerinfo
command:
Workaround
To start the Windows Time service at system startup, use any of the following methods.
Method 1
Run the
sc triggerinfo w32time delete
command to delete the trigger event that's registered as the default setting and to change the Startup Type setting for the Windows Time service from Manual to Automatic:Method 2
Run the
sc triggerinfo w32time start/networkon stop/networkoff
command to define a trigger event that suits your environment. In this example, the command determines whether an IP address is given to a host, and then it starts or stops the service.Method 3
Change the Startup Type of the Windows Time service from Manual to Automatic (Delayed Start).
Note
If the Startup Type of the Windows Time service is set to Automatic (Delayed Start), the Windows Time service may be started by the Time Synchronization before the Service Control Manager starts the Windows Time service task. (This depends on the startup timing of the Windows operating system in question.)
In this situation, the service triggers an automatic stop after the success of the Time Synchronization task. Therefore, if you use Method 3, you must disable the Time Synchronization to avoid the task to start the Windows Time service task. To do this, follow these steps:
- Start the Task Scheduler.
- Under Task Scheduler Library > Microsoft > Windows > Time Synchronization, click Synchronize Time.
- Right-click, and then click Disabled on the shortcut menu.
More information
The Windows Time service on a workgroup computer is not started automatically at system startup by the Trigger-Start service. However, the Windows Time service is started by the Time Synchronization setting that's registered on the Task Scheduler Library at 01:00 a.m. every Sunday for Time Synchronization. Therefore, the default setting can be kept as it is.
-->A service can register to be started or stopped when a trigger event occurs. This eliminates the need for services to start when the system starts, or for services to poll or actively wait for an event; a service can start when it is needed, instead of starting automatically whether or not there is work to do. Examples of predefined trigger events include arrival of a device of a specified device interface class or availability of a particular firewall port. A service can also register for a custom trigger event generated by an Event Tracing for Windows (ETW) provider.
Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP: Service trigger events are not supported until Windows Server 2008 R2 and Windows 7.
A trigger consists of a trigger event type, a trigger event subtype, the action to be taken in response to the trigger event, and (for certain trigger event types) one or more trigger-specific data items. The subtype and the trigger-specific data items together specify the conditions for notifying the service of the event. The format of a data item depends on the trigger event type; a data item can be binary data, a string, or a multistring. Strings must be Unicode; ANSI strings are not supported.
To register for trigger events, the service calls ChangeServiceConfig2 with SERVICE_CONFIG_TRIGGER_INFO and supplies a SERVICE_TRIGGER_INFO structure. The SERVICE_TRIGGER_INFO structure points to an array of SERVICE_TRIGGER structures, each specifying one trigger.
The specified trigger action is taken if the trigger condition is true when the system starts, or if the trigger condition becomes true while the system is running. For example, if a service registers to be started when a particular device is available, the service is started when the system starts if the device is already plugged in to the computer; the service is started when the device arrives if the user plugs in the device while the system is running.
If a trigger has trigger-specific data items, the trigger action is taken only if the data item that accompanies the trigger event matches one of the data items that the service specified with the trigger. Binary data matching is done by bitwise comparison. String matching is case-insensitive. If the data item is a multistring, all strings in the multistring must match.
When a service is started in response to a trigger event, the service receives SERVICE_TRIGGER_STARTED_ARGUMENT as argv[1] in its ServiceMain callback function. Argv[0] is always the short name of the service.
A service that registers to be started in response to a trigger event might stop itself after an idle time-out when the service has no work to do. A service that stops itself must be prepared to handle SERVICE_CONTROL_TRIGGEREVENT control requests that arrive while the service is stopping itself. The SCM sends a SERVICE_CONTROL_TRIGGEREVENT control request whenever a new trigger event occurs while the service is in the running state. To avoid losing trigger events, the service should return ERROR_SHUTDOWN_IN_PROGRESS for any SERVICE_CONTROL_TRIGGEREVENT control request that arrives while the service is transitioning from running to stopped. This instructs the SCM to queue trigger events and wait for the service to enter the stopped state. The SCM then takes the action associated with the queued trigger event, such as starting the service.
When the service is ready to handle trigger events again, it sets SERVICE_ACCEPT_TRIGGEREVENT in its controls-accepted mask in a call to SetServiceStatus. This is usually done when the service calls SetServiceStatus with SERVICE_RUNNING. The SCM then issues a SERVICE_CONTROL_TRIGGEREVENT request for each queued trigger event until the queue is empty.
A service that has dependent services running cannot be stopped in response to a trigger event.
Trigger-start and trigger-stop requests are not guaranteed under low memory conditions.
Use the QueryServiceConfig2 function to retrieve a service's trigger event configuration.
The SC tool (sc.exe) can be used to configure or query a service's trigger events at the command prompt. Use the triggerinfo option to configure a service to start or stop in response to a trigger event. Use the qtriggerinfo option to query the trigger configuration of a service.
Windows Services Manual Trigger Start Ever Foundry -
The following example queries the trigger configuration of the W32time service, which is configured to start when the computer is joined to a domain and stop when the computer leaves the domain.
Windows 10 Services Manual Trigger Start
The following example queries the trigger configuration of the tablet input service, which is configured to start when a HID device with the GUID {4d1e55b2-f16f-11cf-88cb-001111000030} and any of the specified HID device IDs arrives.