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?