Re: Detect network connection
- From: "Ozone" <Ozone@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 4 Jan 2006 12:22:02 -0800
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
>
>
>
.
- References:
- Detect network connection
- From: BMC
- Detect network connection
- Prev by Date: Re: Reading and Writing to the same file
- Next by Date: Re: Reading and Writing to the same file
- Previous by thread: Re: Detect network connection
- Next by thread: Re: Detect network connection
- Index(es):
Relevant Pages
|