How can I configure my Windows NT service to autostart when the system gains Internet access?

Raymond Chen

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.

1 comment

Discussion is closed. Login to edit/delete existing comments.

  • David Walker 0

    So… can you have a service autostart when there is Internet access?

Feedback usabilla icon