Re: Detect network connection

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



If the systems are XP or 2003, you can use the WMI Win32_PingStatus instance
and use the hosts as arguments. This allows you to ping between two hosts
without actually logging into one of them an performing the ping test...

*********SAMPLE SCRIPT***************

Dim sHost 'name of Windows XP computer from which the PING command will be
initiated
Dim sTarget 'name or IP address of remote computer to which connectivity
will be tested
Dim cPingResults 'collection of instances of Win32_PingStatus class
Dim oPingResult 'single instance of Win32_PingStatus class

sHost = "SWYNKPC-XP001"
sTarget = "192.168.12.14"

Set cPingResults = GetObject("winmgmts:{impersonationLevel=impersonate}//" & _
sHost & "/root/cimv2"). ExecQuery("SELECT * FROM Win32_PingStatus " & _
"WHERE Address = '" + sTarget + "'")

For Each oPingResult In cPingResults
If oPingResult.StatusCode = 0 Then
If LCase(sTarget) = oPingResult.ProtocolAddress Then
WScript.Echo sTarget & " is responding"
Else
WScript.Echo sTarget & "(" & oPingResult.ProtocolAddress & ") is
responding"
End If
Wscript.Echo "Bytes = " & vbTab & oPingResult.BufferSize
Wscript.Echo "Time (ms) = " & vbTab & oPingResult.ResponseTime
Wscript.Echo "TTL (s) = " & vbTab & oPingResult.ResponseTimeToLive
Else
WScript.Echo sTarget & " is not responding"
WScript.Echo "Status code is " & oPingResult.StatusCode
End If
Next
***********SAMPLE END*************************

HTH
Ozone

"maximillianx" wrote:

> Could you perform a ping test to a server that you know will always be on?
> Either that, or get local network IP address and if first octet isn't 169 or
> 0, then perform x, etc.?
>
> Just some ideas off the top of my head...
>
> Rob
>
> "BMC" <void@xxxxxxxxxxxxxx> wrote in message
> news:43bbe99c$0$82640$ed2619ec@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> > Hi
> >
> > I need to be able to detect wether a computer has an active network
> > connection by vbscript.
> >
> > Background: This is for logon/logoff scripts which copy files to/from a
> > server, and basically when there isn't a network connection there is an
> > unacceptably long delay for users - basically until the impossible file
> > transfer times out.
> >
> > Any help most appreciated
>
>
>
.



Relevant Pages

  • Re: calling functions at the same time
    ... >plan to timestamp the pings) to test and measure network conditions over ... >different routes to different hosts. ... Putting all the ping hosts in a list ... >> have in mind. ...
    (comp.lang.python)
  • Re: Cant see out to .co.uk from inside my .local domain (forward l
    ... "ping request could not find host xxx please check the name and try again" ... AD DNS space is whatever.local. ... Remove the hosts info. ...
    (microsoft.public.windows.server.sbs)
  • Re: W2K3 servers cant ping each other
    ... W2K3 servers enterprise ed. on my network ... > are able to ping all internet hosts and the other hosts ... > on my own network, and everyone can ping the W2K3 servers... ...
    (microsoft.public.windows.server.networking)
  • Re: Trouble adding user or group
    ... Right click the local area network connection and click Properties. ... Ping desktop ... The Ping command shows that a network connection to the desktop is established. ... The fact that you are using Media Edition should not make any difference here, Media Edition is in fact XP Pro with added media features. ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: View workgroup computers error in XP Home
    ... >XP Home and the other XP Pro. ... The network connection is ... >in the Network Connection Wizard BUT when I go to 'view ... Ping itself by ip address. ...
    (microsoft.public.windowsxp.network_web)