Page 1 of 1

Ping and get IPv4 with VBS

PostPosted: Sat Sep 22, 2012 1:46 am
by Alex
Hi,

I am trying to find a way to ping a hostname and to get the IPv4 with VBS.

Now with this code I only get the IPv6:

Code: Select all
' Ping
publication.nbGetVar "[%2]"

Dim txt

On Error Resume Next

sHost = "[%2]"

For Each oIP in GetObject("winmgmts:").ExecQuery _
("SELECT * FROM Win32_PingStatus WHERE address = '" & sHost & "'")
txt=txt & oIP.ProtocolAddress
Next

publication.nbSetVar "[%1]", txt


Is there a way to get the IPv4? Or maybe to convert IPv6 to IPv4?

Thanks


Alex

Re: Ping and get IPv4 with VBS

PostPosted: Sat Sep 22, 2012 9:10 pm
by dpayer
Alex wrote:Hi,

I am trying to find a way to ping a hostname and to get the IPv4 with VBS.

Now with this code I only get the IPv6:

Code: Select all
' Ping
publication.nbGetVar "[%2]"
Dim txt
On Error Resume Next
sHost = "[%2]"
For Each oIP in GetObject("winmgmts:").ExecQuery _
("SELECT * FROM Win32_PingStatus WHERE address = '" & sHost & "'")
txt=txt & oIP.ProtocolAddress
Next
publication.nbSetVar "[%1]", txt

Is there a way to get the IPv4? Or maybe to convert IPv6 to IPv4?
Thanks
Alex


Alex, if you just do a ping from a command box, does it reply in IPV4 format or in IP6 ?

If six is your network set up as IPv6? That means the IP you are pinging from is an IPV6 address. All IPv4 addresses have direct IPv6 equivalents but not all IPv6 addresses have an IPv4 equivalent. There are many more addresses in IPv6 than v4

David P.

PostPosted: Sat Sep 22, 2012 10:14 pm
by Alex
Hi,

Thanks, yes I got a ipv6 result 'fe80::2cb4:2b04:3f57:fedd'

I need to get something like that: 192.168.1.34

I don't understand why I get an ipv6 because I unchecked all ipv6 format.

Thanks


Alex

PostPosted: Sun Sep 23, 2012 5:38 am
by dpayer
Alex wrote:Hi,

Thanks, yes I got a ipv6 result 'fe80::2cb4:2b04:3f57:fedd'

I need to get something like that: 192.168.1.34

I don't understand why I get an ipv6 because I unchecked all ipv6 format.

Thanks
Alex


Is your router configured to assign IPv6 addresses? Does your provider assign you such address space. If so, you have to live with it.

D