(view source code of pingu.vbs as plain text)
On Error Resume Next
If WScript.Arguments.Count <> 1 Then Syntax( )
Dim pcEngine
CheckEngine( )
Dim WshShell, objExec, input
Set WshShell = CreateObject( "WScript.Shell" )
Do While True
Set objExec = WshShell.Exec( "ping.exe -n 4 -w 15000 " & WScript.Arguments(0) )
input = ""
Do While True
If Not objExec.StdOut.AtEndOfStream Then
input = input & objExec.StdOut.Read(1)
If InStr( input, "TTL=" ) <> 0 Then Exit Do
End If
WScript.Sleep 100
Loop
If InStr( input, "TTL=" ) <> 0 Then Exit Do
Loop
MsgBox "[" & Now & "]" & vbCrLf & vbCrLf & WScript.Arguments(0) & " is now on-line"
Do While objExec.Status <> 1
WScript.Sleep 100
Loop
Sub CheckEngine
pcEngine = LCase( Mid( WScript.FullName, InStrRev( WScript.FullName, "\" ) + 1 ) )
If Not pcEngine = "cscript.exe" Then
Set WshShell = CreateObject( "WScript.Shell" )
WshShell.Run "CSCRIPT.EXE //NoLogo " & Chr(34) _
& WScript.ScriptFullName & Chr(34) _
& " " & WScript.Arguments(0)
WScript.Quit(1)
End If
End Sub
Sub Syntax
strMsg = vbCrLf _
& "PingU.vbs, Version 1.00" & vbCrLf _
& "Notify when a computer gets on-line" & vbCrLf & vbCrLf _
& "Usage: [ CSCRIPT ] PINGU.VBS <hostname>" & vbCrLf _
& " or: [ CSCRIPT ] PINGU.VBS <ip address>" & vbCrLf & vbCrLf _
& "Written by Rob van der Woude" & vbCrLf _
& "http://www.robvanderwoude.com" & vbCrLf & vbCrLf _
& "CheckEngine subroutine by James Lim" & vbCrLf _
& "http://www.windowsitpro.com/Article/ArticleID/48568/48568.html"
WScript.Echo strMsg
WScript.Quit(2)
End Sub
page last modified: 2024-04-16; loaded in 0.0080 seconds