Trigger an Event When Your Internet Connects or Disconnects with Task Scheduler

Launch Windows Task Scheduler from All Programs –> Accessories –> System Tools. Click Action –> Create Task…

Give your task a name in the General tab, and then click Triggers and then click New.

In the “Begin the task” menu, choose “On an event.” Then, choose: Log: Microsoft-Windows-NetworkProfile/Operational Source: NetworkProfile Event ID: 10000 The 10000 Event ID is logged when you connect to a network.

Click OK. Go to the Conditions tab. Here, you might want to uncheck “Start the task only if the computer is on AC power” (for laptops). You may also want to specify a network using the “Start only if the following network connection is available:” menu. This can be handy if you want to only run the task if you are on your work connection, or if you don’t want to run it while on a public network or something like that. Add some actions in the Actions tab and then click OK to finish making your task.

Test it out by disconnecting and then reconnecting your Internet.

It worked! To create an event that’s triggered when the network is disconnected, do everything the same except use 10001 for the Event ID. Log: Microsoft-Windows-NetworkProfile/Operational Source: NetworkProfile Event ID: 10001

You’ll also want to make sure that there aren’t any network connection conditions (since you won’t be connected to the Internet when this happens).

Test it out by disconnecting your network.

Obviously, this is just an example of what’s possible using Windows Task Schedule to watch for events and then doing something interesting… Some for good… and some for evil. BR/Linh Thanks for this info. I’m looking to trigger the task when the network adapter is disabled / enabled (like from device manager). Which event can I use to detect it (Log / source / Event ID)? Thanks in advance. The option is also available in Win7. However, that’s not what I was looking for. I need the task to run whenever it detects that the network card has been disabled/enabled. Thank you for taking the time to check these events. I have already found those EventIDs by myself (I needed only the LAN events). There’s actually another very important EventID: 50033 (LAN interface added) Adding it to trigger my scheduled task solved my specific LAN problem completely. Cheers. 8003 will not trigger in a Win 7 wifi machine that suffers from ‘No Network Access’ on a daily basis. In my case the computer drops internet but continues to be connected to the wifi network. I will look for other EventIDs. I am so close. the limited access (WIFI2) network frequently disconnects.. How to config the task scheduler for this to connect automatically if it disconnects Note : Network conflict already done(Both wifi are working simultaneousy one for internet another one limited access for SFTP connection) I found out by creating the task directly from eventviewer and comparing the differences, because that one worked. In case you’re wondering there’s an app running on an unattended machine. When we lose connection the app crashes. Since it’s a startup program a reboot fixes everything. Just need it to happen once though, call:jdate tnow “%date%” for %%F in (lastrun.txt) do ( call:ftime tfile “%%F” set /a diff=tnow-tfile ) if /I !diff! GTR 0 call:SendEmail REM uncomment next line for testing REM echo.%%~nxF is !diff! days old REM resets file access date to current time and exits copy NUL lastrun.txt GOTO:eof REM Functions start below here :SendEmail REM use any good powershell script powershell -File “C:\….\sendemail.ps1” EXIT /b :ftime JD filename attr SETLOCAL set file=%~2 set attr=%~3 if not defined attr (call:jdate JD “- %~t2” ) ELSE (for /f %%a in (‘”dir %attr% /-c “%file%”|findstr “^^[0-9]””‘) do call:jdate JD “%%a”) ( ENDLOCAL & REM RETURN VALUES IF “%~1” NEQ “” (SET %~1=%JD%) ELSE (echo.%JD%) ) EXIT /b :jdate JD DateStr SETLOCAL set DateStr=%~2&if “%~2″==”” set DateStr=%date% for /f “skip=1 tokens=2-4 delims=(-)” %%a in (‘”echo.|date”‘) do ( for /f “tokens=1-3 delims=/.- ” %%A in (“%DateStr:* =%”) do ( set %%a=%%A&set %%b=%%B&set %%c=%%C)) set /a “yy=10000%yy% %%10000,mm=100%mm% %% 100,dd=100%dd% %% 100” set /a JD=dd-32075+1461*(yy+4800+(mm-14)/12)/4+367*(mm-2-(mm-14)/1212)/12-3((yy+4900+(mm-14)/12)/100)/4 ENDLOCAL & IF “%~1” NEQ “” (SET %~1=%JD%) ELSE (echo.%JD%) EXIT /b Application and services logs > Microsoft > Windows > Universal telemetry client > Operational log 55 is Internet availability, true or false 56 is network available, true or false Comment Name * Email *

Δ  Save my name and email and send me emails as new comments are made to this post.

Windows Task Scheduler  Trigger an Event When Internet Connects or Disconnects - 58Windows Task Scheduler  Trigger an Event When Internet Connects or Disconnects - 94Windows Task Scheduler  Trigger an Event When Internet Connects or Disconnects - 63Windows Task Scheduler  Trigger an Event When Internet Connects or Disconnects - 53Windows Task Scheduler  Trigger an Event When Internet Connects or Disconnects - 90Windows Task Scheduler  Trigger an Event When Internet Connects or Disconnects - 83Windows Task Scheduler  Trigger an Event When Internet Connects or Disconnects - 1Windows Task Scheduler  Trigger an Event When Internet Connects or Disconnects - 5Windows Task Scheduler  Trigger an Event When Internet Connects or Disconnects - 22Windows Task Scheduler  Trigger an Event When Internet Connects or Disconnects - 87Windows Task Scheduler  Trigger an Event When Internet Connects or Disconnects - 23Windows Task Scheduler  Trigger an Event When Internet Connects or Disconnects - 46