Batch File to Maintain Wireless Connection

This is a Windows batch file and a hack for working around intermittent wireless disconnects. If your connection periodically goes to “no internet access”, this script may help. Obviously, it would be better to find and fix the problem but this may keep you going until you do.

This seems so easy that there must be something wrong with it, but I don’t know what that is yet, so I don’t promise anything. It works for me and I can even keep a putty session going with this script running despite frequent intermittent disconnects.

My script figures out the default gateway and the SSID. It pings the default gateway and upon failure, it will reconnect using the SSID. Then it waits 30 seconds and starts over.

I came up with this script after finding plenty of scripts that were pretty close but not quite what I wanted. Some required that you figure out the default gateway and/or the ssid before running the script. Some required the name of the interface. I wanted something that didn’t require my input.

This will open a command window. The command window reports when a reconnection was required and also allows you to hit a key to bypass the 30 second wait period for one round.

@setlocal enableextensions enabledelayedexpansion
@echo off
for /f "tokens=3 delims= " %%a in ('netsh wlan show interfaces ^| findstr "^....SSID"') do (
set ssid=%%a
for /f "tokens=13 delims= " %%a in ('ipconfig ^| findstr "Default.Gateway.*[0-9]"' ) do (
set gateway=%%a
ping -n 1 %gateway% | find "TTL="
if errorlevel 1 (
goto :reset
) else (
@timeout /t 30
goto :loop
time /T
netsh wlan connect %ssid%
@timeout /t 60
goto :loop

Installing Ubuntu 11.10 (Oneiric Ocelot)… All I had to do was check the friggen box!

Installing 11.10 from scratch (erasing the hard drive) on a Dell Inspiron e1505 with Broadcom wireless card … When you see the checkbox about installing third party software, go ahead and put a check in it. You won’t get a chance to install the Broadcom driver later.

Using software-center or the command line, everything I tried resulted in some kind of error. The “Additional Drivers” icon, which is a front end for jockey, showed the drivers that needed to be installed but failed at every attempt to install them. Jockey-text, from the command line, also failed.

It seems to be a problem reading the installation disk post-installation, even with the disk included in the sources list. And of course I had to use the disk because I couldn’t get on line. I haven’t figured it all out and probably won’t.

When I re-installed from scratch, with the 3rd party box checked, the appropriate Broadcom drivers where installed and the system is, so far, working fine.

Wireless with Dell E1505 and Ubuntu 9.10

I use a Dell Inspiron E1505 with a Broadcom BCM4311 wireless card. Before I upgraded to Ubuntu 9.10, I was using ndiswrapper and connecting with a script that I adapted from the popular script. I did not use Gnome’s NetworkManager; in fact, I couldn’t get it to work with my configuration. I like using the command line to control my computer, but when I tried to connect to a wireless network that required a passphrase, I was unable to figure it out.

I upgraded to 9.10 (Karmic Koala) just a couple of days ago. Upgrade might be the wrong word. I partitioned my hard disk, installed Ubuntu 9.10 from a CD which I got from a paper copy of Linux Pro, then copied what I needed and deleted the old Ubuntu. The installation went smoothly. After installation, I found these instructions, which seemed too easy to be true considering some of the other advice for wireless that is currently on the web. In fact it was even easier. I was able to load bcmwl-kernel-source from the CD using Synaptic Package Manager, and the other files installed as dependencies. I did not have to install ndiswrapper.

Now my wireless connections are handled with ease, and network manager even displays a dialog when a passphrase is called for. I’m a little sad about relinquishing control to an automatic system, but it works well.

This, along with some other improvements, makes 9.10 a very good upgrade.