How do I schedule a task to run indefinitely? (Win 10 64-bit)

Doomish

Reputable
Jul 23, 2016
13
0
4,510
Hello. I'm having a weird task scheduler problem that I think some more savvy folks out there might be able to help with. I'm having this weird issue where my internet disconnects just long enough to drop my connection, but not long enough to trigger Windows to reconnect automatically when it comes back up maybe 3 or 4 seconds later. According to my ISP the error is on their end and is a problem with my neighborhood's node, and they won't be fixing it any time soon. So to resolve this on my own, basically I have set up a task to monitor my connection with a batch file by doing a ping to google (just for simplicity's sake) and if it's unsuccessful then disable/reenable my ethernet network.

m1tGpgW.png

This is all of the code, there's nothing more to it than this. The problem I'm having is that I set up the task to run, but I don't know how to make it execute indefinitely once I start it running. Currently it activates at startup, but goes back to 'ready' after checking the scheduler again and does not work when my internet drops. It also gives a 'last run result' of (0x1). If I just run this by itself when I'm having connectivity problems it works fine.

My settings for the task are as follows:
https://i.imgur.com/IbFr5zv.png
https://i.imgur.com/BX9507P.png
https://i.imgur.com/pIoPAaF.png

Keep in mind that I don't want it to repeat every x minutes, I want it to restart and run again as soon as it ends, indefinitely.

Alternatively, is there a way to have Windows monitor my connection by itself and then execute a task if it disconnects? That way I can just avoid doing the ping at all.
 
Solution
You woukd need to write something. But it would still be in efficient and hammer your CPU If done improperly

I suggest try AutoIt or AutoHotKey forums for solutions like that

Doomish

Reputable
Jul 23, 2016
13
0
4,510
That worked! However, I think I'd rather not go this route after all because it is extremely inefficient and generates a CMD prompt a thousand miles long in seconds. Can anyone think of a better way than what I have devised? Maybe the alternative method I suggested?
 
actually put goto loop before :end

for cmd output use @echo off at first line of your script
Code:
@echo off
:loop
ping -n 1 google.com
if %errorlevel% EQU 0 goto end
netsh interface set interface "Ethernet" DISABLED
timeout 5
netsh interface set interface "Ethernet" ENABLED
goto loop
:end