batchfile for internet reconnect

Dora Daff

Estimable
Jul 18, 2014
2
0
4,510
Hi, i want to create a batch file that scans if my pc is connected to the internet and if its not connected the script executes bachfile 1 (called ipconfig renew.bat)

ipconfig /release
ping -n 5 127.0.0.1
ipconfig /renew

my solution for this "problem" wouldve been

@echo off
:loop
ping www.google.com -n 1 -w 5000 > nul
if errorlevel 1 "ipconfig renew.bat"
ping -n 30 127.0.0.1 > nul
goto loop

but after the script has executed "ipconfig renew.bat" it closes and doesnt loop.
So how should i rewrite this?