Tom's Guide | Tom's Hardware | Tom's Games | PC Safety Suite
![]() |
![]() |
![]() |
Comment:
I've searched a couple of hours for a simple ping script in Visual Basic 5, but only found more or less complicated ones. There must be a simple way in VB to perform:
if { server alive } then
msgbox "ok"
else
msgbox "not ok"
end ifwithout coding hundreds of lines, or isn't it? I'm not interested in detailed responses from ping, I just want to know if the server is alive or not.
I'd be grateful if someone can point me to a simple example script.
+1 | ![]() |
I am not sure whether it works in all version. It works in my Vista.
if WScript.Arguments.Count > 0 then
set PingedRet = GetObject("winmgmts://./root/cimv2").ExecQuery( "SELECT * FROM Win32_PingStatus WHERE Address = '" & WScript.Arguments.Item(0) & "'" )
pinged = False
For Each someObj In PingedRet
If someObj.StatusCode = 0 Then
pinged = True
End If
Next
If pinged = false then
MsgBox("Address " & WScript.Arguments.Item(0) & " can not be reached")
else
MsgBox("Address " & WScript.Arguments.Item(0) & " is alive !")
end if
else
MsgBox("Ping what ? Usage: VBPing ip.address.or.host.name" )
end if--
Holla.
+1 | ![]() |
Thanks for your reply.
After some search on the net, it seems to me that the script is using the Win32_PingStatus class. As I'm a newbie in Visual Basic...how do I add this class to my script? Is it built-into Windows XP or do I have to download it from somewhere?
+1 | ![]() |
legolas,
have you tried creating a .vbs file with the above content?
Just cut and paste this into notepad and save the file as VBPing.vbs on windows directory.Then from the start menu -> run , type
VBPing the.host.name
later,--
Holla.
+1 | ![]() |
Yes, it works stand-alone called from a command prompt and also inside a VB 5 application. Great :-)
thanks
![]() |
time cues with video play...
|
batch file help with csv ...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.