Computing.Net > Forums > Programming > Simple ping script in VB5

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to get for your free account now!

Simple ping script in VB5

Reply to Message Icon

Name: legolas
Date: November 2, 2008 at 01:03:58 Pacific
OS: Win XP
CPU/Ram: 800 MHz/512 MB
Manufacturer/Model: HP
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 if

without 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.


Report Offensive Message For Removal

Sponsored Link
Ads by Google

Response Number 1
Name: Holla
Date: November 5, 2008 at 23:42:26 Pacific
Reply:

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.


Report Offensive Follow Up For Removal

Response Number 2
Name: legolas
Date: November 6, 2008 at 02:34:05 Pacific
Reply:

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?


Report Offensive Follow Up For Removal

Response Number 3
Name: Holla
Date: November 6, 2008 at 04:45:00 Pacific
Reply:

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.


Report Offensive Follow Up For Removal

Response Number 4
Name: legolas
Date: November 7, 2008 at 04:42:30 Pacific
Reply:

Yes, it works stand-alone called from a command prompt and also inside a VB 5 application. Great :-)

thanks


Report Offensive Follow Up For Removal
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Simple ping script in VB5

Simple design questions in C++ www.computing.net/answers/programming/simple-design-questions-in-c/4384.html

Simple Batch Script help www.computing.net/answers/programming/simple-batch-script-help/12744.html

Printing/Emailing in VB5 www.computing.net/answers/programming/printingemailing-in-vb5/14741.html