Script To Monitor Internet Connectivity and Automatically Reset Wireless Connection

Ehlo,

So, We have a non stable Wireless access point, non stable Internet connection!

and at times we will get that yellow triangle with the exclamation mark on the WIFI connection on our PCs, and the only way to restore the connection is to Disconnect/and reconnect to the wireless AP.

I wrote this batch to automate this process, It could be written by another ways, but I find this simple and straight forward.

What the batch file do is:

Ping a Public IP –> If failed –> Try again after 1 Minute –> If still failed –> Disconnect from the wireless network –> Wait for 1 Minute –> Connect to the wireless network –> Start over again.

Prerequisites:

1- Name your Wireless card as WAN (or edit the batch to reflect your wireless “card name”).

2- replace YourWirelessSSID in the batch with your actual wireless network name (SSID).

3- If required,  make the batch starts with your windows startup, so it runs automatically.

The Batch:

@Echo off
:Start
CLS

Rem ####################Ping Check#####################

Ping 4.2.2.2 |find "TTL=" && GOTO Start
Ping -n 60 127.0.0.1 >nul
Ping 4.2.2.2 |find "TTL=" && GOTO Start

Rem ###########Reset The Wireless Network##############

netsh wlan disconnect interface=WAN
Ping -n 60 127.0.0.1 >nul
Echo.
netsh wlan connect ssid=YourWirelessSSID name=YourWirelessSSID interface=WAN
Ping -n 10 127.0.0.1 >nul

GOTO Start

 

Note: tested on Win 7

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s