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
|