Here's the current NetCheck program that seems to work reasonably well here on my netbook with both wired and wireless connection, it requires use of Group Policy Editor and as such it's restricted to Pro+ versions of Windows - I've only tested it on XP Pro SP3.
Caveat: Currently it doesn't reinitialise itself to display on the logon screen if the current user logs off - that's about it. I'm still looking at fixing this by calling it again, (probably needs higher privileges so it can display on the logon screen again).
#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_Res_Icon_Add=On.ico
#AutoIt3Wrapper_Res_Icon_Add=Off.ico
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
Global $inifile = @WindowsDir & "\NetCheck.ini"
If Not FileExists($inifile) Then _Initialise()
$TIP=IniRead($inifile,"Main","TestServer","8.8.8.8")
$TPort=IniRead($inifile,"Main","TestPort","53")
$TTime=IniRead($inifile,"Main","TimeOut","100")
$HotKey=IniRead($inifile,"Main","Hotkey","+!\")
HotKeySet($HotKey, "_Exit")
If $CmdLine[0] > 0 Then
Select
Case $CmdLine[1] = "logon"
$logon = 1
Case $CmdLine[1] = "startup"
$logon = 0
Case Else
EndSelect
Else
$logon = 0
EndIf
Opt('TCPTimeout', $TTime)
TCPStartup()
If $logon Then TraySetState()
While 1
If (ProcessExists("explorer.exe") > 0) And (Not $logon) Then ExitLoop
$socket = TCPConnect($TIP, $TPort)
If $socket = -1 Then
If $logon Then
TraySetIcon(@ScriptName, -6)
TraySetToolTip("Network disconnected!")
Else
ToolTip("Not Connected", 0, 0,"Network Status", 3, 5)
EndIf
Else
TCPCloseSocket($socket)
If $logon Then
TraySetIcon(@ScriptName, -5)
TraySetToolTip("Network connected")
Else
ToolTip("Connected", 0, 0,"Network Status", 1, 5)
EndIf
EndIf
Sleep(5000)
WEnd
Func _Exit()
TCPShutdown()
Exit
EndFunc
Func _Initialise()
IniWrite($inifile, "Main", "TestServer", "8.8.8.8")
IniWrite($inifile, "Main", "TestPort", "53")
IniWrite($inifile, "Main", "TTime", "100")
IniWrite($inifile, "Main", "Hotkey", "+!\")
$file = FileOpen($inifile, 1)
FileWrite($file, @CRLF & "; Where: TestServer = IP address of a server to make a test connection to." & @CRLF & "; TestPort = Server port to make a test connection to." & @CRLF & "; TimeOut = Test connection timeout value in milliseconds. Test will" & @CRLF & "; fail if it can't make a connection in this time." & @CRLF & "; Hotkey = Key sequence to terminate program." & @CRLF & "; + = Shift" & @CRLF & "; ! = Alt" & @CRLF & "; ^ = Control" & @CRLF & "; # = Windows")
FileClose($file)
EndFunc
To set it up, copy it to both of the following directories, (not really required in two locations, just makes the script dialogue easier later):
C:\Windows\System32\Group Policy\Machine\Scripts\Startup
C:\Windows\System32\Group Policy\User\Scripts\Logon
Run the Group Policy Editor, (eg. Start->Run->gpedit.msc):
IDEA: Wireless sensorSpecify a Windows Startup script as follows:
IDEA: Wireless sensorand a User Logon script as follows, (
Note the 'logon' parameter):
IDEA: Wireless sensorOn first run it will create the file C:\Windows\NetCheck.ini for which the defaults are:
[Main]
TestServer=8.8.8.8
TestPort=53
TimeOut=100
Hotkey="+!\"It'll try connecting to Googles' DNS server, if it doesn't make a connection within 100ms it assumes there's no access. You can change it to use your local DHCP server, (port 67 by default), since that's where your laptop IPs come from.
It only reads from the file upon execution, so if you make a change you need to stop then start it again. You can run it from the CLI - just remember to add the 'logon' parameter since you'll be logged in.
Nothing bad will happen if you forget, it'll just exit immediately because it sees the explorer.exe process.
You can kill it either by right-clicking on the tray icon and selecting Exit, or the default hotkey combination of Shift+Alt+\ .
It still only tries to connect every 5 seconds, I didn't see a need to make it any faster.
The ini file is the only thing it writes to the drive, the tray icons are stored in the exe - I've only added them to the archive in case you want to do some fiddling and recompile.
In theory, if all goes well, on the next reboot you should end up with:
IDEA: Wireless sensorAnd after log on:
IDEA: Wireless sensorStill thinking of trying to make it a service but I couldn't get it to interact with the Desktop - installed and ran OK, was getting all the right answers just didn't display anything - more reading required me thinks.