2
\$\begingroup\$

There is a remote Windows PC that has access to "landline" unmetered WiFi and there is a Verizon 4G LTE MiFi (metered WiFi) as backup. This script checks to see if the PC is connected to any WiFi, connected to metered WiFi, or has any internet connection. It will be called a few times a day by Task Scheduler. Everything seems to work OK while testing at home.

@echo off
SETLOCAL enabledelayedexpansion

rem get computer name
set host=%COMPUTERNAME%
set wifi=
if "%host%"=="HOME" (
    set landline=xxx
    set metered=Verizon-4GLTE-xxx-xxxx
)
if "%host%"=="WORK" (
    set landline="xxx spaces in name xxx"
    set metered=Verizon-4GLTE-xxx-xxxx
)
echo.
echo **************************************************
echo %host%
echo landline wifi = !landline!
echo metered wifi = !metered!
echo **************************************************
echo.
echo.
echo ping test and if no response, connect to !metered! ...
echo *************************************************************************************
ping 8.8.8.8 -n 1 || netsh wlan connect name=!metered!
echo *************************************************************************************
timeout /t 10

echo.
echo Attempting to connect to landline wifi %landline% ...
netsh wlan connect name=%landline%
timeout /t 10

echo.
echo.
echo Fail safe...
echo ping test and if no response, connect to !metered! ...
echo *************************************************************************************
ping 8.8.8.8 -n 1 || netsh wlan connect name=!metered!
echo *************************************************************************************
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.