You can test if an internet is connected by using FOR /F
& netsh interface show interface^|find "Connected"
. This will search for all connected networks to your device.
From here we can use echo %%B | findstr "Wi-Fi" > Nul
to filter the result's down to the Wi-Fi
and use IF %ERRORLEVEL% EQU 0
to tell if it exists or not (Thus telling us if its online or not)
FOR /F "tokens=3,*" %%A IN ('netsh interface show interface^|find "Connected"') DO echo %%B | findstr "Wi-Fi" > Nul
IF %ERRORLEVEL% EQU 0 (GOTO :CONNECTED) ELSE (GOTO :DISCONNECTED)
Not sure if you need both to be connected or not due to your lack of description, but to do this you change the (GOTO :CONNECTED) ELSE (GOTO :DISCONNECTED)
to variables (example: (SET C1=ONLINE) ELSE (SET C1=OFFLINE)
) and stack a new FOR /F
for the next network. Then using an IF /I ""==""
statement, you can compare the variables to see if both are "Online".
IF /I "%C1%"=="ONLINE" (IF /I "%C2%"=="ONLINE" (GOTO :ONLINE) ELSE (GOTO :OFFLINE)) ELSE (GOTO :OFFLINE)
Be sure to use the following command to find the Interface Name of your network for the findstr
command.
netsh interface show interface