When configuring a Windows NT service, you can set the SERVICE_TRIGGER_INFO to include a SERVICE_TRIGGER that uses the SERVICE_TRIGGER_TYPE_IP_ADDRESS_AVAILABILITY trigger, so that it starts and stops based on whether the system has network access.
| Â | Start when access gained | Stop when access lost |
|---|---|---|
dwTrigger |
SERVICE_TRIGGER_TYPE_IP_ADDRESS_AVAILABILITY |
|
dwAction |
SERVICE_TRIGGER_ACTION_SERVICE_START |
SERVICE_TRIGGER_ACTION_SERVICE_STOP |
pTriggerSubtype |
&NETWORK_MANAGER_FIRST_IP_ADDRESS_ARRIVAL_GUID |
&NETWORK_MANAGER_LAST_IP_ADDRESS_REMOVAL_GUID |
Note that this will run your service when the system has an IP address, which is not the same as saying that the system has Internet access. It could be on an intranet, or it could be stuck behind a captive portal.
So… can you have a service autostart when there is Internet access?