Ever find yourself on a Windows box with sporadically disconnecting dialup? Ever needed to just nip out and do something, having to balance it with the fact that wget -c will be sure to break as soon as you leave the room?
Fear no more. You can just use the following VBScript; rename "YourConnection" to the name of your dialup connection, save it to whatever.vbs, and run the file.
set WshShell = WScript.CreateObject("WScript.Shell")
const Key = "HKLM\System\CurrentControlSet\Services\RemoteAccess\"
const SubKey = "Remote Connection"
While True
' If not connected to the internet, try to connect
If WshShell.RegRead(Key & SubKey)(0) = 0 Then
WshShell.Run "rundll32.exe rnaui.dll,RnaDial YourConnection"
WScript.Sleep 500 ' Allow the DUN interface to load
WshShell.SendKeys "{ENTER}"
WScript.Sleep 30000 ' Allow thirty seconds to connect
End If
' Wait ten seconds before checking again
WScript.Sleep 10000
Wend
It checks the Windows registry every ten seconds to find out whether the box is connected or not, and if not, it'll automatically dial the selected connection and wait 30 seconds for it to connect.
A simple bit of glue, but rather useful. Enjoy.