Question : VBscript for ping -t

i need a script that can give me an audable alarm when ping responds , I am attempting to be notified when the power returns to the site and things will boot and respond to the ping and i want to be woken up.  Thanks!

Answer : VBscript for ping -t

Hi, you can try this code.

If you have an audio file in MP3 format (or something Windows Media Player can play), this will play that file when a machine responds to Ping.  When the computer is offline again, Windows Media Player will be closed, and when it is online again, the file will play.

Regards,

Rob.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
Set objWMP = Nothing

strComputer = "REMOTEPCNAME"
strMediaFile = "C:\temp\AlarmFile.mp3"

While True
	If Ping(strComputer) = True Then
		If objWMP Is Nothing Then Set objWMP = CreateObject("WMPlayer.OCX")
		objWMP.openPlayer strMediaFile
	Else
		Set objShell = CreateObject("WScript.Shell")
		objShell.Run "taskkill /F /IM wmplayer.exe", 0, True
	End If
	' Wait 30 seconds
	WScript.Sleep 30000
Wend

Function Ping(strComputer)
	Dim objShell, boolCode
	Set objShell = CreateObject("WScript.Shell")
	boolCode = objShell.Run("Ping -n 1 -w 300 " & strComputer, 0, True)
	If boolCode = 0 Then
		Ping = True
	Else
		Ping = False
	End If
End Function
Random Solutions  
 
programming4us programming4us