Final changes (hopefully)
code:
Break ON
; Set address list to all the hosts you want to monitor.
$asAddressList="130.11.21.1","10.0.0.2","steed.sgb.co.uk"
Dim $aiStatus[UBound($asAddressList)+1]
$iInterval=60 ; Number of seconds between checks
$sSound="c:\windows\media\chimes.wav" ; Path to sound to play
While "true"
$sMessage=""
For $iIndex=0 To Ubound($asAddressList)
$sAddress=$asAddressList[$iIndex]
$iStatus=$aiStatus[$iIndex]
If fnMonitorIP($sAddress)
If $iStatus
$sMessage=$sMessage+@TIME+" Address " + $sAddress + " is now unavailable." +@CRLF
EndIf
$aiStatus[$iIndex]=0
Else
If $iStatus=0
$sMessage=$sMessage+@TIME+" Address " + $sAddress + " is responding." +@CRLF
EndIf
$aiStatus[$iIndex]=1
EndIf
Next
If $sMessage <> ""
Play $sSound
$sMessage
$Null=MessageBox("$sMessage","Change in monitored station status",0,5)
EndIf
Sleep($iInterval)
Loop
Function fnMonitorIP($sAddress)
Shell '%COMSPEC% /C ping -n 1 ' + $sAddress + ' >/dev/null'
$fnMonitorIP=@ERROR
Return
EndFunction
This version works as before with the following changes:
- The message and sound are only displayed once for each workstation as it comes onto the network.
- An alert is displayed when a monitored workstation is removed from the network, and an alert will be subsequently displayed if it re-appears.
A history of the workstation connecting/disconnecting will be present on the console.