I have a Windows XP machine that I'm accessing remotely which has tendancy to get into a weird state with the network connection - when you're on the machine locally it shows as connected still but nothing gets through. Disabling and Enabling the network connection solves the problem. I guess this symptomatic of a more serious problem, but I can't get to the machine to sort it out until at least Monday, so I was hoping to either find some utility or put to together a quick script to test the network connection (i.e. telnet google.com 80
or something) and restart the network connection if possible or else reboot the machine. Googling on this suggests only really complicated lash-ups, and I don't want to lock myself out before I can get to it... Can anyone suggest something simple? Or even a way to automatically restart the connection every couple of hours?
From the command prompt you can use:
You can paste that into a new text file, save with a
.BAT
or.CMD
extension then set up a scheduled task to launch however often you want.However, I would recommend trying to update the driver and if it doesn't work, buy a PCI network card, you can get cheap ones for around £2 which are more than capable of doing the job.
If you're going to punt and reboot, at least test the connection first; so if you can't retrieve something over the internet, then reboot. We can quibble about you punting on 2nd down with 70 to go, but it's just silly to punt on every 2nd down.
EDIT: After further reflection and curiosity, here's the PowerShell way of doing this, with some bonus ideas. No need to mess with schedules, it automatically sleeps for three minutes, so just run it once on startup (
powershell -File testandpunt.ps1
). I've added a simple counter, so it doesn't reboot until three failed attempts. Obviously, change any of these values. Changedserverfault.com
togoogle.com
since the latter is probably faster and i'd rather you siphon their bandwidth.TestAndPunt.ps1:
ORIGINAL ANSWER: There are probably better ways, but i've written a little script to only restart if the connection fails. If you don't or can't use vbs, then curl or python or perl or whatever can do the same thing.
So, you'll be able to schedule it tighter--say, every five minutes--to cut down on the restarts and reduce the max time your connection is down.
TestAndPunt.vbs:
What I've done for now is to schedule the following as a task every 30 mins:
So if it dies, worst case I will be back on in under 40 mins. It does mean I've got to be ready with
shutdown -a
when I'm using it.Anyone know if it might do any harm to leave your machine rebooting every half hour?