Source language: Translate to:

Ping and get IPv4 with VBS

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

Ping and get IPv4 with VBS

Postby Alex » Sat Sep 22, 2012 1:46 am

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
 
Posts: 745
Joined: Sat Mar 04, 2006 4:53 am

Re: Ping and get IPv4 with VBS

Postby dpayer » Sat Sep 22, 2012 9:10 pm

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.
User avatar
dpayer
 
Posts: 1380
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Postby Alex » Sat Sep 22, 2012 10:14 pm

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
Alex
 
Posts: 745
Joined: Sat Mar 04, 2006 4:53 am

Postby dpayer » Sun Sep 23, 2012 5:38 am

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
User avatar
dpayer
 
Posts: 1380
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA


Return to NeoBook Action Commands

Who is online

Users browsing this forum: Bing [Bot] and 1 guest