﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ping (WMI &amp; Non-WMI Versions) - Functions &amp; Simple Connectivity Monitor</title><link>http://www.visualbasicscript.com/</link><description /><copyright>(c) VBScript Forum</copyright><ttl>30</ttl><item><title> RE: Ping (WMI &amp; Non-WMI Versions) - Functions &amp; Simple Connectivity Monitor (pnasim)</title><description>  good one </description><link>http://www.visualbasicscript.com/fb.ashx?m=62668</link><pubDate>Thu, 24 Jul 2008 06:43:21 GMT</pubDate></item><item><title> RE: Ping (WMI &amp; Non-WMI Versions) - Functions &amp; Simple Connectivity Monitor (dm_4ever)</title><description>  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. &lt;br&gt;   &lt;br&gt;  &lt;b&gt;Read/Write to a text file&lt;/b&gt;...do a search for &lt;b&gt;FileSystemObject &lt;/b&gt;and the &lt;b&gt;OpenTextFile &lt;/b&gt;method:&amp;nbsp; &lt;a href="http://msdn2.microsoft.com/en-us/library/z9ty6h50.aspx" target="_blank" rel="nofollow"&gt;http://msdn2.microsoft.com/en-us/library/z9ty6h50.aspx&lt;/a&gt; &amp;amp; &lt;a href="http://msdn2.microsoft.com/en-us/library/314cz14s.aspx" target="_blank" rel="nofollow"&gt;http://msdn2.microsoft.com/en-us/library/314cz14s.aspx&lt;/a&gt; &lt;br&gt;  &lt;b&gt;Ping&lt;/b&gt;...well you have plenty of examples in this post &lt;br&gt;  &lt;b&gt;Executing Net View&lt;/b&gt; and &lt;b&gt;UpTime&lt;/b&gt;...do a search for &lt;b&gt;WSHSHell &lt;/b&gt;and the &lt;b&gt;Run &lt;/b&gt;method:&amp;nbsp; &lt;a href="http://msdn2.microsoft.com/en-us/library/d5fk67ky.aspx" target="_blank" rel="nofollow"&gt;http://msdn2.microsoft.com/en-us/library/d5fk67ky.aspx&lt;/a&gt; &lt;br&gt;  &lt;b&gt;Checking Services&lt;/b&gt;...the example you posted is already using &lt;b&gt;WMI &lt;/b&gt;and the code would be almost the same without the &lt;b&gt;$&lt;/b&gt; &lt;br&gt;   &lt;br&gt;  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.&amp;nbsp; 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.&amp;nbsp; If you have specific questions about something or an error...feel free to post in the &lt;b&gt;&lt;a href="http://www.visualbasicscript.com/forumid_2/tt.htm" target="_blank" rel="nofollow"&gt;WSH &amp;amp; Client Side VBScript&lt;/a&gt; &lt;/b&gt;forum. </description><link>http://www.visualbasicscript.com/fb.ashx?m=51063</link><pubDate>Wed, 22 Aug 2007 21:17:01 GMT</pubDate></item><item><title> RE: Ping (WMI &amp; Non-WMI Versions) - Functions &amp; Simple Connectivity Monitor (wsmoth)</title><description>  dm, &lt;br&gt;  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... &lt;br&gt;   &lt;br&gt;  I have a Kixtart script that takes this concept a bit further but it does not have a GUI. &lt;br&gt;   &lt;br&gt;  Here is the Kix Script: &lt;br&gt;  &lt;blockquote&gt;&lt;pre class="prettyprint"&gt;
 Break On
 CLS
 
 Del '%windir%\RebootCheckError.log'
 Del '%Windir%\RebootCheck.log'
 Del '%windir%\RebootCheckServices.log'
 $Error&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = "N"
 $LoggedErrorOnce = "N"
 
 ;**********************
 ;
 ;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Main
 ;
 ;**********************
 :Main
 If Open(1,"c:\servers.txt") = 0
 &amp;nbsp; $Server = ReadLine(1)
 &amp;nbsp; 
 &amp;nbsp; While @ERROR = 0
 &amp;nbsp;&amp;nbsp;&amp;nbsp; $Continue = "Y"
 &amp;nbsp;&amp;nbsp;&amp;nbsp; $LogText&amp;nbsp; = "@CRLF------------------------------------------------------------@CRLFChecking $Server started @Date @Time@CRLF------------------------------------------------------------"
 &amp;nbsp;
 &amp;nbsp;&amp;nbsp;&amp;nbsp; Gosub LogIt
 &amp;nbsp;&amp;nbsp;&amp;nbsp; Gosub PingTest
 &amp;nbsp;
 &amp;nbsp;&amp;nbsp;&amp;nbsp; If $Continue = "Y"
 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Gosub NetView
 &amp;nbsp;&amp;nbsp;&amp;nbsp; EndIf
 &amp;nbsp;
 &amp;nbsp;&amp;nbsp;&amp;nbsp; If $Continue = "Y"
 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Gosub Uptime
 &amp;nbsp;&amp;nbsp;&amp;nbsp; EndIf
 &amp;nbsp;
 &amp;nbsp;&amp;nbsp;&amp;nbsp; If $Continue = "Y"
 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Gosub CheckServices
 &amp;nbsp;&amp;nbsp;&amp;nbsp; EndIf
 &amp;nbsp;
 &amp;nbsp;&amp;nbsp;&amp;nbsp; $LoggedErrorOnce = "N"
 &amp;nbsp;&amp;nbsp;&amp;nbsp; $Server = ReadLine(1)
 &amp;nbsp; Loop
 &amp;nbsp; 
 &amp;nbsp; $CloseFile = Close(1)
 
 EndIf
 Gosub Results
 Quit
 
 
 ;**********************
 ;
 ;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Ping Test
 ;
 ;**********************
 :PingTest
 ? "Pinging $Server....@CRLF@CRLF"
 Shell '%Comspec% /c Ping $Server -n 3 |find /I "Reply from"'
 
 If @ERROR = 0
 &amp;nbsp; $LogText&amp;nbsp; = "PING RESULT&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - Ping successful"
 &amp;nbsp; $Continue = "Y"
 Else
 &amp;nbsp; If $LoggedErrorOnce = "N"
 &amp;nbsp;&amp;nbsp;&amp;nbsp; Shell '%Comspec% /c Echo $Server - Ping failed.&amp;gt;&amp;gt;%windir%\RebootCheckError.log'
 &amp;nbsp;&amp;nbsp;&amp;nbsp; $LoggedErrorOnce = "Y"
 &amp;nbsp; EndIf
 &amp;nbsp; $Error&amp;nbsp;&amp;nbsp;&amp;nbsp; = "Y"
 &amp;nbsp; $LogText&amp;nbsp; = "PING RESULT - Ping failed."
 &amp;nbsp; $Continue = "N"
 EndIf
 
 Gosub LogIt
  
 Return
 
 ;**********************
 ;
 ;&amp;nbsp;&amp;nbsp;&amp;nbsp; Net View Test
 ;
 ;**********************
 :NetView
 ? "@CRLF@CRLFNet viewing $Server...@CRLF@CRLF"
 Shell '%Comspec% /c Net View \\$Server'
 If @ERROR = 0
 &amp;nbsp; $LogText&amp;nbsp; = "NET VIEW RESULT - Net View successful"
 &amp;nbsp; $Continue = "Y"
 Else
 &amp;nbsp; If $LoggedErrorOnce = "N"
 &amp;nbsp;&amp;nbsp;&amp;nbsp; Shell '%Comspec% /c Echo $Server - Net view failed&amp;gt;&amp;gt;%windir%\RebootCheckError.log'
 &amp;nbsp;&amp;nbsp;&amp;nbsp; $LoggedErrorOnce = "Y"
 &amp;nbsp; EndIf
 &amp;nbsp; $Error&amp;nbsp;&amp;nbsp;&amp;nbsp; = "Y"
 &amp;nbsp; $LogText&amp;nbsp; = "NET VIEW RESULT - Net view failed"
 &amp;nbsp; $Continue = "N"
 EndIf 
 Gosub LogIt
 
 Return
 
 ;**********************
 ;
 ;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Uptime
 ;
 ;**********************
 :Uptime
 ? "@CRLF@CRLFQuerying uptime for $Server...@CRLF"
 $LogText = "UPTIME RESULT&amp;nbsp;&amp;nbsp; - "
 Gosub LogIt
 Shell '%Comspec% /c Uptime &amp;gt;%windir%\RebootCheck.Log'"&amp;gt;\\$Server&amp;gt;&amp;gt;%windir%\RebootCheck.Log'
 Shell '%Comspec% /c Uptime \\$Server'
 Return
 
 ;**********************
 ;
 ;&amp;nbsp;&amp;nbsp; Check Services
 ;
 ;**********************
 :CheckServices
 $objWMIService = GetObject("winmgmts:\\"+ $Server + "\root\cimv2")
 $colItems&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = $objWMIService.ExecQuery("Select * from Win32_Service")
 
 For Each $objItem in $colItems
 &amp;nbsp; &amp;nbsp; &amp;nbsp;
 &amp;nbsp; ? "Checking Service - " + $objItem.Name
  &amp;nbsp;
 &amp;nbsp; If $objItem.StartMode = "Auto"
 &amp;nbsp;&amp;nbsp;&amp;nbsp; ? "&amp;nbsp; " + $objItem.Name + " is set to auto, querying status..."
 &amp;nbsp;
 &amp;nbsp;&amp;nbsp;&amp;nbsp; If $objItem.State &amp;lt;&amp;gt; "Started" And $objItem.State &amp;lt;&amp;gt; "Running"
 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $LogText = "SERVICE CHECK&amp;nbsp;&amp;nbsp; - " + $objItem.DisplayName + " - NOT STARTED!!!"
 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Gosub LogIt
 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $Error&amp;nbsp;&amp;nbsp; = "Y"
 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Shell '%Comspec% /c Echo $Server - SERVICE ' + $objItem.DisplayName + ' - NOT STARTED!!!&amp;gt;&amp;gt;%windir%\RebootCheckError.log'
 &amp;nbsp;&amp;nbsp;&amp;nbsp; Else
 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&amp;nbsp;&amp;nbsp; $LogText = "&amp;nbsp; Started - "+ $objItem.DisplayName 
 &amp;nbsp;&amp;nbsp;&amp;nbsp; EndIf
 &amp;nbsp;&amp;nbsp; 
 &amp;nbsp; Else
 
 &amp;nbsp;&amp;nbsp;&amp;nbsp; ? "&amp;nbsp; " + $objItem.Name + " not set to auto, skipping."
 &amp;nbsp;
 &amp;nbsp; EndIf
  
 
 Next
 Return
 
 ;**********************
 ;
 ;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Results
 ;
 ;**********************
 :Results
 If $Error = "Y"
 &amp;nbsp; $Msg = MessageBox("One or more errors were encountered on one or more servers.@CRLF@CRLFTwo log files have been created:@CRLF - RebootCheck.Log - Contains a list of all output from tests.@CRLF - RebootCheckError.Log - A list of servers that an error was produced on@CRLF@CRLFLogs are located at %windir%\RebootCheck.log and %windir%\RebootCheckError.log.","Errors encountered.",48)
 &amp;nbsp; Run '%Comspec% /c Notepad %windir%\RebootCheck.log'
 &amp;nbsp; Run '%Comspec% /c Notepad %windir%\RebootCheckError.log'
 
 Else
 &amp;nbsp; $Msg = MessageBox("No errors were encountered. Opening %windir%\RebootCheck.log.","No Errors",64)
 &amp;nbsp; Run '%Comspec% /c Notepad %windir%\RebootCheck.log'
 EndIf
 Return
 
 ;**********************
 ;
 ;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Logging
 ;
 ;**********************
 :LogIt
 $Log = RedirectOutput("%Windir%\RebootCheck.log")
  ? "$LogText"
 $Log = RedirectOutput("")
 ? "$LogText"
 Return
 &lt;/pre&gt; &lt;br&gt;  &lt;/blockquote&gt;&lt;b&gt;EDIT://Placed code in code blocks - dm_4ever&lt;/b&gt; &lt;br&gt;   &lt;br&gt;  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! &lt;br&gt;   &lt;br&gt;  Thanks, &lt;br&gt;  Will </description><link>http://www.visualbasicscript.com/fb.ashx?m=51047</link><pubDate>Wed, 22 Aug 2007 10:46:27 GMT</pubDate></item><item><title> RE: Ping (WMI &amp; Non-WMI Versions) - Functions &amp; Simple Connectivity Monitor (CondoPC)</title><description>  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). &lt;br&gt;  Once you build a filtered list, you only need to keep it updated on a schedule. Then use your dropdown to validate the&amp;nbsp;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. &lt;br&gt;   </description><link>http://www.visualbasicscript.com/fb.ashx?m=50972</link><pubDate>Mon, 20 Aug 2007 13:58:43 GMT</pubDate></item><item><title> RE: Ping (WMI &amp; Non-WMI Versions) - Functions &amp; Simple Connectivity Monitor (guitarguy2576)</title><description>  Definitely good insight.... &lt;br&gt;  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. &lt;br&gt;  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. </description><link>http://www.visualbasicscript.com/fb.ashx?m=50954</link><pubDate>Sun, 19 Aug 2007 20:12:38 GMT</pubDate></item><item><title> RE: Ping (WMI &amp; Non-WMI Versions) - Functions &amp; Simple Connectivity Monitor (dm_4ever)</title><description>  If your AD has a lot of outdated computer records then it sounds like you may want work&amp;nbsp; on some clean up scripts.&amp;nbsp; 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.&amp;nbsp;  &lt;br&gt;   &lt;br&gt;  As for pinging...it is a basic connectivity check.&amp;nbsp; &lt;a href="http://en.wikipedia.org/wiki/Ping" target="_blank" rel="nofollow"&gt;http://en.wikipedia.org/wiki/Ping&lt;/a&gt; &lt;br&gt;   &lt;br&gt;  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. &lt;br&gt;   &lt;br&gt;  Depending on the size of your organization...you should consider investing into a system like MS SMS to deploy software or make changes. &lt;br&gt;   &lt;br&gt;  You might also consider deploying a login script that will gather a computers information and write it to a centralized database of some sort. &lt;br&gt;   </description><link>http://www.visualbasicscript.com/fb.ashx?m=50953</link><pubDate>Sun, 19 Aug 2007 19:32:45 GMT</pubDate></item><item><title> RE: Ping (WMI &amp; Non-WMI Versions) - Functions &amp; Simple Connectivity Monitor (guitarguy2576)</title><description>  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. &lt;br&gt;  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??? </description><link>http://www.visualbasicscript.com/fb.ashx?m=50950</link><pubDate>Sun, 19 Aug 2007 17:18:13 GMT</pubDate></item><item><title> RE: Ping (WMI &amp; Non-WMI Versions) - Functions &amp; Simple Connectivity Monitor (4scriptmoni)</title><description>  Amazing job!!! &lt;br&gt;  Great GUI, I also want to try to make an .hta. Also checked your site, I will make a link to it from mine.. &lt;br&gt;   &lt;br&gt;  regards, &lt;br&gt;   </description><link>http://www.visualbasicscript.com/fb.ashx?m=46768</link><pubDate>Tue, 08 May 2007 07:54:28 GMT</pubDate></item><item><title> RE: Ping (WMI &amp; Non-WMI Versions) - Functions &amp; Simple Connectivity Monitor (dm_4ever)</title><description>  &lt;img src="http://www.visualbasicscript.com/upfiles/smiley/s6.gif" alt="" /&gt;&amp;nbsp; I'm glad you liked it. </description><link>http://www.visualbasicscript.com/fb.ashx?m=45249</link><pubDate>Fri, 30 Mar 2007 18:30:02 GMT</pubDate></item><item><title> RE: Ping (WMI &amp; Non-WMI Versions) - Functions &amp; Simple Connectivity Monitor (mcds99)</title><description>  The Connectivity Monitor is SO COOL! &lt;br&gt;   &lt;br&gt;  I love scripts that have KISMIF! &lt;br&gt;   &lt;br&gt;  (Keep It Simple Make It Fun!) &lt;br&gt;   </description><link>http://www.visualbasicscript.com/fb.ashx?m=45167</link><pubDate>Thu, 29 Mar 2007 06:57:12 GMT</pubDate></item><item><title> RE: Ping (WMI &amp; Non-WMI Versions) - Functions &amp; Simple Connectivity Monitor (dm_4ever)</title><description>  Added a Non-WMI Reachable Ping Function for those using Win2k. </description><link>http://www.visualbasicscript.com/fb.ashx?m=43861</link><pubDate>Tue, 27 Feb 2007 20:16:13 GMT</pubDate></item><item><title> Ping (WMI &amp; Non-WMI Versions) - Functions &amp; Simple Connectivity Monitor (dm_4ever)</title><description>  So I've seen a few requests lately concerning the ability to ping to check for connectivity within a vbscript.&amp;nbsp; Most implementations I've seen call ping.exe using the exec method of wscript.shell and read the output via stdout.&amp;nbsp; While this works just fine, I think using WMI to ping is cleaner and easier to work with.&amp;nbsp; 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.&amp;nbsp; I hope some find this useful and if you have other Ping related ideas, let me know. &lt;br&gt;   &lt;br&gt;  The &lt;font color="#990000"&gt;Reachable &lt;/font&gt;function will return &lt;font color="#000099"&gt;&lt;font color="#0000cc"&gt;True or False&lt;/font&gt; &lt;font color="#000000"&gt;depending on whether the address provided is reachable or not. The address can be provided with an IP address or Computer Name &lt;br&gt;  The &lt;/font&gt;&lt;/font&gt;&lt;font color="#990000"&gt;ResolveIP &lt;/font&gt;function will return an &lt;font color="#0000cc"&gt;IPAddress &lt;/font&gt;that corresponds to the Computer Name you provide &lt;br&gt;   &lt;br&gt;  &lt;b&gt;Added 1/29/07&lt;/b&gt; - I put together a simple &lt;font color="#990000"&gt;"Connectivity Monitor" &lt;/font&gt;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): &lt;a href="http://dm4ever1.googlepages.com/ConnectivityMonitor.zip" target="_blank" rel="nofollow"&gt;ConnectivityMonitor&lt;/a&gt; &lt;br&gt;   &lt;br&gt;  Reference for this class: &lt;a href="http://msdn2.microsoft.com/en-us/library/aa394350.aspx" target="_blank" rel="nofollow"&gt;http://msdn2.microsoft.com/en-us/library/aa394350.aspx&lt;/a&gt; &lt;br&gt;  &lt;b&gt;NOTE:&lt;/b&gt; WMI is &lt;b&gt;NOT &lt;/b&gt;required on the host being ping'd. &lt;br&gt;   &lt;br&gt;  &lt;b&gt;&lt;font color="#990000"&gt;Reachable Function (WinXP/Win2k3)&lt;/font&gt;&lt;/b&gt; &lt;br&gt;  &lt;pre class="prettyprint"&gt;
 '==========================================================================
 ' The following function will test if a machine is reachable via a ping
 ' using WMI and the Win32_PingStatus Class
 '==========================================================================
 If Reachable("10.50.138.48") Then
  WScript.Echo "Computer is Reachable!"
 Else 
  WScript.Echo "Computer is Unreachable!"
 End If
 
 Function Reachable(strComputer)
 ' &amp;nbsp;&amp;nbsp;&amp;nbsp; On Error Resume Next
 
  Dim wmiQuery, objWMIService, objPing, objStatus
  
  wmiQuery = "Select * From Win32_PingStatus Where Address = '" &amp;amp; strComputer &amp;amp; "'"
  
  Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
  Set objPing = objWMIService.ExecQuery(wmiQuery)
  
  For Each objStatus in objPing
  &amp;nbsp;&amp;nbsp;&amp;nbsp; If IsNull(objStatus.StatusCode) Or objStatus.Statuscode&amp;lt;&amp;gt;0 Then
  &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Reachable = False 'if computer is unreacable, return false
  &amp;nbsp;&amp;nbsp;&amp;nbsp; Else
  &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Reachable = True 'if computer is reachable, return true
  &amp;nbsp;&amp;nbsp;&amp;nbsp; End If
  Next
 End Function
 &lt;/pre&gt; &lt;br&gt;   &lt;br&gt;  &lt;b&gt;&lt;font color="#990000"&gt;Reachable Function - Non WMI Version (Win2k/WinXP/Win2k3)&lt;/font&gt;&lt;/b&gt; &lt;br&gt;  &lt;pre class="prettyprint"&gt;
 If Reachable("10.50.138.48") Then
  WScript.Echo "Computer is Reachable!"
 Else
  WScript.Echo "Computer is Unreachable!"
 End If
 
 Function Reachable(strComputer)
 '&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; On Error Resume Next
 
  Dim objShell, objExec, strCmd, strTemp
  
  strCmd = "ping -n 1 " &amp;amp; strComputer
  
  Set objShell = CreateObject("WScript.Shell")
  Set objExec = objShell.Exec(strCmd)
  strTemp = UCase(objExec.StdOut.ReadAll)
  
  If InStr(strTemp, "REPLY FROM") Then
 &amp;nbsp; Reachable = True 
  Else
 &amp;nbsp; Reachable = False
  End If
 End Function
 &lt;/pre&gt; &lt;br&gt;   &lt;br&gt;  &lt;b&gt;&lt;font color="#990000"&gt;ResolveIP Function (WinXP/Win2k3)&lt;/font&gt;&lt;/b&gt; &lt;br&gt;  &lt;pre class="prettyprint"&gt;
 '==========================================================================
 ' The following function will resolve a computer name to its ip address
 ' using WMI and the Win32_PingStatus Class
 '==========================================================================
 WScript.Echo ResolveIP("HOSTNAME")
 
 Function ResolveIP(strComputer)
 Dim wmiQuery : wmiQuery = "Select * From Win32_PingStatus Where Address = '" &amp;amp; strComputer &amp;amp; "'"
 
 Dim objWMIService : Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
 Dim objPing : Set objPing = objWMIService.ExecQuery(wmiQuery)
 Dim objStatus
 For Each objStatus in objPing
 &amp;nbsp;&amp;nbsp; If IsNull(objStatus.StatusCode) Or objStatus.Statuscode&amp;lt;&amp;gt;0 Then
 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ResolveIP = "Computer is Unreachable!"
 &amp;nbsp;&amp;nbsp; Else
 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ResolveIP = objStatus.ProtocolAddress
 &amp;nbsp;&amp;nbsp; End If
 Next
 End Function
 &lt;/pre&gt; &lt;br&gt;   &lt;br&gt;  &lt;b&gt;&lt;font color="#990000"&gt;ResolveIP Function (Win2k/WinXP/Win2k3)&lt;/font&gt;&lt;/b&gt; &lt;br&gt;  &lt;pre class="prettyprint"&gt;
 WScript.Echo ResolveIP("Computer1")
 
 Function ResolveIP(computerName)
 &amp;nbsp;&amp;nbsp;&amp;nbsp; Dim objShell&amp;nbsp; :&amp;nbsp; Set objShell = CreateObject("WScript.Shell")
 &amp;nbsp;&amp;nbsp;&amp;nbsp; Dim objExec&amp;nbsp;&amp;nbsp; :&amp;nbsp; Set objExec = objShell.Exec("ping " &amp;amp; computerName &amp;amp; " -n 1")
 &amp;nbsp;&amp;nbsp;&amp;nbsp; Dim strOutput : strOutput = objExec.StdOut.ReadAll
 &amp;nbsp;&amp;nbsp;&amp;nbsp; Dim RegEx&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; :&amp;nbsp; Set RegEx = New RegExp
 &amp;nbsp;&amp;nbsp;&amp;nbsp; RegEx.Pattern = "\[(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\]"
 &amp;nbsp;&amp;nbsp;&amp;nbsp; RegEx.Global = True
 &amp;nbsp;&amp;nbsp;&amp;nbsp; If RegEx.Test(strOutput) Then
 &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ResolveIP = RegEx.Execute(strOutput)(0).Submatches(0)
 &amp;nbsp;&amp;nbsp;&amp;nbsp; Else
 &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ResolveIP = "IP Address could not be resolved."
 &amp;nbsp;&amp;nbsp;&amp;nbsp; End If
 End Function
 &lt;/pre&gt; &lt;br&gt;   &lt;br&gt;  [image]local://11180/2BF856EFE52B457E953D3AD42CE190F2.jpg[/image] </description><link>http://www.visualbasicscript.com/fb.ashx?m=42535</link><pubDate>Fri, 26 Jan 2007 18:04:28 GMT</pubDate></item></channel></rss>
