Link to home
Start Free TrialLog in
Avatar of Vlearns
Vlearns

asked on

VB doubt


Does someone know how this can be done?

i want to enter a host name  through a input edit box

then i want to ping the host name using a command line so that i can retrieve the ip adress of that machine.

so that

vv.xx.yy.zz  hostname in the 'hosts' file at

C:\WINDOWS\system32\drivers\etc

basically the problem is that is there some way so that  

i can accept the host name from the user.
then find the ip address of that machine using say

ping hostname.com????????

is there any other way i can obtain the ip of the machine.

and add the entry to hosts file  as above.


i have the code that writes to the hosts file .

i want some way to obtain the ip of the machine, given the host name in my application .



i know this seems tough. Can you help me with this.













ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of List244
List244

Well, what are you trying to get the IP of?
A domain? If it is a domain you are trying
to track, you can simply connect to the
domain in place of IP, and then check
which IP you are connected to.
Avatar of Vlearns

ASKER

no actually i know machines by their names.
so abc.def.com

i want the user to type in this name and be able to retrieve their ip address. i do not know how to do that using vb

pinging might be a primitive solution.
do you know a better way?

If you are using VB.net then this is the best way:

     System.Net.Dns.GetHostByName("www.microsoft.com").AddressList(0).ToString()

This will return the IP Address of www.microsoft.com
You just input a hostname and it returns the ipaddress.
If you are using VB6 then you have to use about a million lines of code but it can be done:

This website contains all the code:

http://vbnet.mvps.org/index.html?code/network/iplookup.htm
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Vlearns

ASKER

i figured it out
thanks all
Hi Vlearns,

What's your solution, who make the helps here? ;-)