![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Hostname -> IP Address Any ideas on how best to get the IP address of a hostname, using VBScript? Right now I'm exec'ing a ping command, which gives output like this: =============================================== H:\>ping cmp092 Pinging cmp092.example.com [167.190.237.59] with 32 bytes of data: Reply from 167.190.237.59: bytes=32 time=1ms TTL=128 Reply from 167.190.237.59: bytes=32 time<1ms TTL=128 Reply from 167.190.237.59: bytes=32 time<1ms TTL=128 Reply from 167.190.237.59: bytes=32 time<1ms TTL=128 Ping statistics for 167.190.237.59: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 1ms, Average = 0ms =============================================== I iterate through line for line, find the one that starts with "Pinging" and then use a regex to pull out the IP address into a collection. Any better ideas? -todd |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Hostname -> IP Address "Todd Walton" <tdwalton@xxxxxx> wrote in message news:ed68aae7-0520-4ced-b746-4e7e0374d0bc@xxxxxx Quote: > Any ideas on how best to get the IP address of a hostname, using > VBScript? Right now I'm exec'ing a ping command, which gives output > like this: > > =============================================== > > H:\>ping cmp092 > > Pinging cmp092.example.com [167.190.237.59] with 32 bytes of data: > > Reply from 167.190.237.59: bytes=32 time=1ms TTL=128 > Reply from 167.190.237.59: bytes=32 time<1ms TTL=128 > Reply from 167.190.237.59: bytes=32 time<1ms TTL=128 > Reply from 167.190.237.59: bytes=32 time<1ms TTL=128 > > Ping statistics for 167.190.237.59: > Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), > Approximate round trip times in milli-seconds: > Minimum = 0ms, Maximum = 1ms, Average = 0ms > > =============================================== > > I iterate through line for line, find the one that starts with > "Pinging" and then use a regex to pull out the IP address into a > collection. > > Any better ideas? > > -todd @echo off for /F "tokens=3 delims=: " %%a in ('ping HostName ^| find /i "bytes="') do set IP=%%a |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Hostname -> IP Address Todd Walton wrote: Quote: > Any ideas on how best to get the IP address of a hostname, using > VBScript? Right now I'm exec'ing a ping command, which gives output > like this: > > =============================================== > > H:\>ping cmp092 > > Pinging cmp092.example.com [167.190.237.59] with 32 bytes of data: > > Reply from 167.190.237.59: bytes=32 time=1ms TTL=128 > Reply from 167.190.237.59: bytes=32 time<1ms TTL=128 > Reply from 167.190.237.59: bytes=32 time<1ms TTL=128 > Reply from 167.190.237.59: bytes=32 time<1ms TTL=128 > > Ping statistics for 167.190.237.59: > Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), > Approximate round trip times in milli-seconds: > Minimum = 0ms, Maximum = 1ms, Average = 0ms > > =============================================== > > I iterate through line for line, find the one that starts with > "Pinging" and then use a regex to pull out the IP address into a > collection. > IP address of the local computer: http://www.rlmueller.net/PingComputers.htm The page explains what is required for each function. -- Richard Mueller MVP Directory Services Hilltop Lab - http://www.rlmueller.net -- |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Hostname -> IP Address "Todd Walton" <tdwalton@xxxxxx> wrote in message news:ed68aae7-0520-4ced-b746-4e7e0374d0bc@xxxxxx Quote: > Any ideas on how best to get the IP address of a hostname, using > VBScript? Right now I'm exec'ing a ping command, which gives output > like this: > > =============================================== > > H:\>ping cmp092 > > Pinging cmp092.example.com [167.190.237.59] with 32 bytes of data: > > Reply from 167.190.237.59: bytes=32 time=1ms TTL=128 > Reply from 167.190.237.59: bytes=32 time<1ms TTL=128 > Reply from 167.190.237.59: bytes=32 time<1ms TTL=128 > Reply from 167.190.237.59: bytes=32 time<1ms TTL=128 > > Ping statistics for 167.190.237.59: > Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), > Approximate round trip times in milli-seconds: > Minimum = 0ms, Maximum = 1ms, Average = 0ms > > =============================================== > > I iterate through line for line, find the one that starts with > "Pinging" and then use a regex to pull out the IP address into a > collection. > > Any better ideas? above. This is the link to the Microsoft page: http://msdn.microsoft.com/en-us/libr...50(VS.85).aspx Below is a small sample: sHost = "MYCOMPUTER" For Each oIP in GetObject("winmgmts:").ExecQuery _ ("SELECT * FROM Win32_PingStatus WHERE address = '" & sHost & "'") sIP = oIP.ProtocolAddress Next MsgBox sIP, , sHost |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Hostname -> IP Address On Sep 11, 4:07*pm, "James Whitlow" <jwhitlow.60372...@xxxxxx> wrote: Quote: > * * You can use 'Win32_PingStatus Class' if you are using Windows XP or > above. This is the link to the Microsoft page:http://msdn.microsoft.com/en-us/libr...50(VS.85).aspx Thank you James. -todd |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Net use with hostname fails, IP address works fine | Vista networking & sharing | |||
| Extract hostname from distinguished name | PowerShell | |||
| Hostname to IP translation | PowerShell | |||
| Invalid Hostname | Vista networking & sharing | |||