Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple Ping question

Status
Not open for further replies.

Staticfactory

IS-IT--Management
Mar 1, 2005
79
CA
I'm using this function to ping machines before trying to connect to them for various reporting...

Code:
Function ping(hostname)
    set wshShell = CreateObject("WScript.Shell")
    ping = Not CBool(wshShell.run("ping -n 1 " & hostname,0,True))
End Function

I'm aware that this is limited to Windows 2003 and XP networks, but a machine running W2k3/XP should be able to ping anything with an ip using this function right? I can't see why a Windows 98 machine, for example, would not reply to the ping this function is creating.
 
hi there

Looks like your not getting the output from the command line, try this I did a search in the site for some code. Brownie points go to user "tsuji"

surl="localhost"
signature="TTL"

set wshshell=createobject("wscript.shell")
set oexec=wshshell.exec("ping " & surl)

do while oexec.status=0 : wscript.sleep 100 : loop
soutput=oexec.stdout.readall

if instr(1, soutput, signature, 1)<>0 then
wscript.echo "The url is alive."
else
wscript.echo "The url is unavailable or unknown; or the response is blocked."
end if

set oexec=nothing : set wshshell=nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top