A. The Windows Management Instrumentation (WMI) classes in Windows XP and later provide a Win32_PingStatus object that you can use to ping a machine. The following script, which you can download at http://www.windowsitpro.com/content/content/48449/vbpinging.zip uses this object to ping a passed hostname or IP address. Because of space constraints, some lines wrap to two lines.

                              Option Explicit                              Dim strHost                              ' Check that all arguments required have been passed.                              If Wscript.Arguments.Count 0 then                                  Ping = False                                          'WScript.Echo "Status code is " & objRetStatus.StatusCode                                      else                                          Ping = True                                          'Wscript.Echo "Bytes = " & vbTab & objRetStatus.BufferSize                                          'Wscript.Echo "Time (ms) = " & vbTab & objRetStatus.ResponseTime                                          'Wscript.Echo "TTL (s) = " & vbTab & objRetStatus.ResponseTimeToLive                                      end if                                  next                              End Function                               

You can modify this script to do whatever you need. Notice that I've commented out some lines (') that give more information about the ping attempt, but you can leave the lines in if the information would be useful to you. Run the script by using the following command:

                              D:\projects\VBScripts>cscript vbping.vbs savdalex01                              
which will give the following sample output:

Host savdalex01 contacted

You can find more information about Win32_PingStatus at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_pingstatus.asp .