Reputation: 416
IM looking for a better solution. checking the computer for if the computer is online and if its in the correct network. The reason for this is that the rest of the batch need network, and is printing a log to a lan printer. Se my code for what i use today.
@ECHO off
COLOR f8
TITLE WLAN CHECK
REM Maskin pinger www.vg.no
:wlancheck
ping www.vg.no>nul
if errorlevel 1 goto nonet
if errorlevel 0 goto gotnet
:nonet
color cf
echo [WLAN CHECK][:::::::::FAILED!::::::::]
echo THE COMPUTER HAS NO INTERNET CONNECTION
ECHO CONNECT NOW!!!
timeout /t 15
Goto wlancheck
:gotnet
color cf
I use the same for ping my printer.
The best solution for me is if there was a way " if connected to snid blablabla" goto continue echo not connected please retry.
Upvotes: 0
Views: 48
Reputation: 73526
ipconfig
can be used:
ipconfig | find /i "MY_WLAN_CONNECTION_NAME" >nul && goto continue || echo not connected
Replace MY_WLAN_CONNECTION_NAME
with your connection name as seen in the output of ipconfig
when the connection is established.
Upvotes: 1