Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Ping (WMI & Non-WMI Versions) - Functions & Simple Connectivity Monitor

 
Logged in as: Guest
arrSession:exec spGetSession 2,16,42535
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> Post a VBScript >> Ping (WMI & Non-WMI Versions) - Functions & Simple Connectivity Monitor
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Ping (WMI & Non-WMI Versions) - Functions & Simple Conn... - 1/26/2007 12:04:28 PM   
  dm_4ever


Posts: 2172
Score: 32
Joined: 6/29/2006
From: Orange County, California
Status: offline
So I've seen a few requests lately concerning the ability to ping to check for connectivity within a vbscript.  Most implementations I've seen call ping.exe using the exec method of wscript.shell and read the output via stdout.  While this works just fine, I think using WMI to ping is cleaner and easier to work with.  There is no need to read the output and try to extract what you want from a string like you do when using ping.exe.  I hope some find this useful and if you have other Ping related ideas, let me know.

The Reachable function will return True or False depending on whether the address provided is reachable or not. The address can be provided with an IP address or Computer Name
The
ResolveIP function will return an IPAddress that corresponds to the Computer Name you provide

Added 1/29/07 - I put together a simple "Connectivity Monitor" using Win32_PingStatus (I've attached a screen shot of what it looks like). You can download it from here (I put it in a zip because of the images used for it): ConnectivityMonitor

Reference for this class: http://msdn2.microsoft.com/en-us/library/aa394350.aspx
NOTE: WMI is NOT required on the host being ping'd.

Reachable Function (WinXP/Win2k3)

      

Reachable Function - Non WMI Version (Win2k/WinXP/Win2k3)

      

ResolveIP Function (WinXP/Win2k3)

      

ResolveIP Function (Win2k/WinXP/Win2k3)

      


Thumbnail Image


Attachment (1)

< Message edited by dm_4ever -- 5/19/2008 7:48:17 AM >


_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm
 
 
Revisions: 18 | Post #: 1
 
 RE: Ping (WMI & Non-WMI Versions) - Functions & Simple ... - 2/27/2007 2:16:13 PM   
  dm_4ever


Posts: 2172
Score: 32
Joined: 6/29/2006
From: Orange County, California
Status: offline
Added a Non-WMI Reachable Ping Function for those using Win2k.

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to dm_4ever)
 
 
Post #: 2
 
 RE: Ping (WMI & Non-WMI Versions) - Functions & Simple ... - 3/29/2007 12:57:12 AM   
  mcds99


Posts: 407
Score: 4
Joined: 2/28/2006
Status: offline
The Connectivity Monitor is SO COOL!

I love scripts that have KISMIF!

(Keep It Simple Make It Fun!)

_____________________________

Sam

Keep it Simple Make it Fun KiSMiF

(in reply to dm_4ever)
 
 
Post #: 3
 
 RE: Ping (WMI & Non-WMI Versions) - Functions & Simple ... - 3/30/2007 12:30:02 PM   
  dm_4ever


Posts: 2172
Score: 32
Joined: 6/29/2006
From: Orange County, California
Status: offline
  I'm glad you liked it.

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to mcds99)
 
 
Post #: 4
 
 RE: Ping (WMI & Non-WMI Versions) - Functions & Simple ... - 5/8/2007 1:54:28 AM   
  4scriptmoni


Posts: 184
Score: 0
Joined: 5/3/2007
Status: offline
Amazing job!!!
Great GUI, I also want to try to make an .hta. Also checked your site, I will make a link to it from mine..

regards,

_____________________________

Enterprise Microsoft Scripts
Exchange, Login/Logout Monitor,TS, Monitoring, Security, AD, etc...
http://www.xoroz.com

(in reply to mcds99)
 
 
Post #: 5
 
 RE: Ping (WMI & Non-WMI Versions) - Functions & Simple ... - 8/19/2007 11:18:13 AM   
  guitarguy2576

 

Posts: 13
Score: 0
Joined: 7/14/2007
Status: offline
Just wondering.... is a ping really the best way to do this? I'm just wondering how the connectivity for a computer is checked by an OS. Does it literally ping every single computer before showing you which ones are available? If it doesn't... then isn't there some way to tap into that information source to show a faster result for all the computer in a network.
I've been working (off and on) to make something that checks a specific OU's list of computers and then makes sure that they are online before listing them. From there, I would be able to get an accurate list of the computers I needed to send a certain installation file to a startup folder etc. Our active directory is filled with outdated computers, and nobody has enough time to sift through them all...... yet. Any ideas on computer verification???

(in reply to dm_4ever)
 
 
Post #: 6
 
 RE: Ping (WMI & Non-WMI Versions) - Functions & Simple ... - 8/19/2007 1:32:45 PM   
  dm_4ever


Posts: 2172
Score: 32
Joined: 6/29/2006
From: Orange County, California
Status: offline
If your AD has a lot of outdated computer records then it sounds like you may want work  on some clean up scripts.  Each computer would have a "LastLogonTimeStamp" value...the thing with that is that you would have to query all domain controllers since I don't believe this information gets replicated. 

As for pinging...it is a basic connectivity check.  http://en.wikipedia.org/wiki/Ping

As for speed...controlling and initiating several scripts to do the ping and write it to something like a database may be a bit faster.

Depending on the size of your organization...you should consider investing into a system like MS SMS to deploy software or make changes.

You might also consider deploying a login script that will gather a computers information and write it to a centralized database of some sort.

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to guitarguy2576)
 
 
Post #: 7
 
 RE: Ping (WMI & Non-WMI Versions) - Functions & Simple ... - 8/19/2007 2:12:38 PM   
  guitarguy2576

 

Posts: 13
Score: 0
Joined: 7/14/2007
Status: offline
Definitely good insight....
It wasn't so much that I was against pinging as it is the fact that our company has a weird setup. We got bought out by another company a few years ago, and they have basically taken over our domain. We have our own little "nook", but they still are the end all be all when it comes to monitoring the entire domain. Since they monitor the network for pings that might represent harmful worms etc, I run the risk of my network connection being shut down when I'm just trying to populate one of our larger branches list of computers.
I do need to look into querying the last login for our computers. Quite honestly, I'm just trying to get a grasp on all the things you can do with scripting. I wish some of this stuff would have been taught to me in college instead of a lot of the useless "variety programming" I was put through. I'm getting certain concepts, but as time goes on, I can see how in depth it all can get. Thanks for the suggestions and help though... This is one of the most useful sites I've come across.

< Message edited by guitarguy2576 -- 8/20/2007 10:52:47 AM >

(in reply to dm_4ever)
 
 
Revisions: 1 | Post #: 8
 
 RE: Ping (WMI & Non-WMI Versions) - Functions & Simple ... - 8/20/2007 7:58:43 AM   
  CondoPC


Posts: 118
Score: 0
Joined: 7/23/2007
Status: offline
If you are looking at validating your records pulled from AD, then lastlogin property of the AD record would work. You can also compare that to DNS records and DHCP lease time to get a filtered list of known computer accounts that dhave been on the network in x days (based on your DNS and DHCP record scavenging).
Once you build a filtered list, you only need to keep it updated on a schedule. Then use your dropdown to validate the accounts between AD and your filtered list. That would eliminate your need for ping. Your records may not be 100% accurate, but you at least would not have any records older than your update interval.

(in reply to guitarguy2576)
 
 
Post #: 9
 
 RE: Ping (WMI & Non-WMI Versions) - Functions & Simple ... - 8/22/2007 4:46:27 AM   
  wsmoth

 

Posts: 2
Score: 0
Joined: 8/22/2007
Status: offline
dm,
Great GUI, nice start but a basic connectivity test only tells you if the server is up, it does not tell you if all the services are up and responding and if the shares are available...

I have a Kixtart script that takes this concept a bit further but it does not have a GUI.

Here is the Kix Script:

      
EDIT://Placed code in code blocks - dm_4ever

If you could accomplish something along these same lines with that beautiful interface, I think you would have a really winner. I am not skilled enough with vb to convert this Kix to vb but if you wanted to convert it, and then add your great GUI to it, I would greatly apprecaite it!

Thanks,
Will

< Message edited by dm_4ever -- 8/22/2007 3:03:11 PM >

(in reply to dm_4ever)
 
 
Revisions: 1 | Post #: 10
 
 RE: Ping (WMI & Non-WMI Versions) - Functions & Simple ... - 8/22/2007 3:17:01 PM   
  dm_4ever


Posts: 2172
Score: 32
Joined: 6/29/2006
From: Orange County, California
Status: offline
I really don't have a need for a VBScript version of the KIX script you posted and I already know how to do everything that is required so there is not much to be gained on my part.

Read/Write to a text file...do a search for FileSystemObject and the OpenTextFile method:  http://msdn2.microsoft.com/en-us/library/z9ty6h50.aspx & http://msdn2.microsoft.com/en-us/library/314cz14s.aspx
Ping...well you have plenty of examples in this post
Executing Net View and UpTime...do a search for WSHSHell and the Run method:  http://msdn2.microsoft.com/en-us/library/d5fk67ky.aspx
Checking Services...the example you posted is already using WMI and the code would be almost the same without the $

It is not that I don't think the script would be useful to others or that I don't want to help...helping those who are willing to put forth an effort to do it on their own is what many of us look for.  Perhaps you will get lucky and someone will provide you with what you need, but if you have other scripts to convert you might as well start learning and doing this on your own...as much as possible of course.  If you have specific questions about something or an error...feel free to post in the WSH & Client Side VBScript forum.

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to wsmoth)
 
 
Post #: 11
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> Post a VBScript >> Ping (WMI & Non-WMI Versions) - Functions & Simple Connectivity Monitor Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts