IP to Computer name? 
Author Message
 IP to Computer name?

Is there a way I can resolve a known IP address to the PC to which it
currently belongs?  I.E.  I have a script that collects the IP
addresses of PCs logged into the server, now I need a VBScript
function that will resolve those IP addresses to hostnames.

Any ideas would be appreciated
Michael



Mon, 08 Nov 2004 00:59:17 GMT  
 IP to Computer name?
Look at MABRY Software GetHostX DLL component - it's not free but it's very
good.

Other than that you're looking at a DNS query which I have no experience of
so I can't help you with that directly.

Chris Barber.


Is there a way I can resolve a known IP address to the PC to which it
currently belongs?  I.E.  I have a script that collects the IP
addresses of PCs logged into the server, now I need a VBScript
function that will resolve those IP addresses to hostnames.

Any ideas would be appreciated
Michael



Mon, 08 Nov 2004 01:32:56 GMT  
 IP to Computer name?
System Scripting Runtime - freeware. Has a DNS Lookup.

http://www.netal.com/Software/SSR14.ZIP

--
Gurgen Alaverdian
http://www.gurgensvbstuff.com

Quote:
> Is there a way I can resolve a known IP address to the PC to which it
> currently belongs?  I.E.  I have a script that collects the IP
> addresses of PCs logged into the server, now I need a VBScript
> function that will resolve those IP addresses to hostnames.

> Any ideas would be appreciated
> Michael



Mon, 08 Nov 2004 01:48:00 GMT  
 IP to Computer name?

Quote:

> Is there a way I can resolve a known IP address to the PC to which it
> currently belongs?  I.E.  I have a script that collects the IP
> addresses of PCs logged into the server, now I need a VBScript
> function that will resolve those IP addresses to hostnames.

> Any ideas would be appreciated
> Michael

If you are looking for NetBIOS name (just the computer name, and not
the fully qualified domain name) check out:

http://www.interclasse.com/scripts/PingerCLS.html

specifically the "getHostName(sIP)" method. Although this one is
in JScript, you can "do your own" in VBS along the same or similar
lines (should you feel that VBS is a must), or just wrap it up in
JScript function that you will call from your *.wsf script in VBS
(have on mind that you can not instantiate JScript "class" object
from within VBS and v.v.- that's why wrapper function suggestion).

Branimir



Mon, 08 Nov 2004 02:57:06 GMT  
 IP to Computer name?

Quote:

> Is there a way I can resolve a known IP address to the PC to which it
> currently belongs?  I.E.  I have a script that collects the IP
> addresses of PCs logged into the server, now I need a VBScript
> function that will resolve those IP addresses to hostnames.

Here is a function that uses nslookup.exe that comes with WinNT, Win2k and
WinXP.

It is based on a script from
http://www.asp101.com/articles/jason/reversedns/default.asp, but I have modified
it heavily.

It supports now e.g. both lookup and reverse lookup, it will detect if the input
parameter is an ip address or not and act accordingly.

WScript.Echo NSlookup("www.microsoft.com")
WScript.Echo NSlookup("desktop-3.some.ert.com")
WScript.Echo NSlookup("250.124.58.9")
WScript.Echo NSlookup("127.0.0.1")

Function NSlookup(sHost)
    ' Both IP address and DNS name is allowed
    ' Function will return the opposite

    Set oRE = New RegExp
    oRE.Pattern = "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$"
    bInpIP = False
    If oRE.Test(sHost) Then
        bInpIP = True
    End If

    Set oShell = CreateObject("Wscript.Shell")
    'Run NSLookup via Command Prompt
    'Dump results into a temp text file
    oShell.Run "%ComSpec% /c nslookup " & sHost _
        & "> C:\" & sHost & ".txt", 0, True

    'Open the temp Text File and Read out the Data
    Set oFS = CreateObject("Scripting.FileSystemObject")
    Set oTF = oFS.OpenTextFile("C:\" & sHost & ".txt")

    'Parse the text file
    Do While Not oTF.AtEndOfStream
        sLine = Trim(oTF.Readline)
        If LCase(Left(sLine, 5)) = "name:" Then
            sData = Trim(Mid(sLine, 6))
            If Not bInpIP Then
                'Next line will be IP address(es)
                'Line can be prefixed with "Address:" or "Addresses":
                aLine = Split(oTF.Readline, ":")
                sData = Trim(aLine(1))
            End If
            Exit Do
        End If
    Loop

    'Close it
    oTF.Close
    'Delete It
    oFS.DeleteFile "C:\" & sHost & ".txt"

    If Lcase(TypeName(sData)) = LCase("Empty") Then
        NSlookup = ""
    Else
        NSlookup = sData
    End If
End Function

--
torgeir



Mon, 08 Nov 2004 05:05:38 GMT  
 IP to Computer name?
I came across this one too and it seems to be the best solution.  I
was hoping for an internal, native way of doing this, but the SSR
works well.

Thanks for all the suggestions!
Michael



Quote:
>System Scripting Runtime - freeware. Has a DNS Lookup.

>http://www.netal.com/Software/SSR14.ZIP



Tue, 09 Nov 2004 00:13:18 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. View IP Addresses/Computer Names/NIC Speed from a specific port

2. someone Stole my IP address - Computer name by IP ?

3. Get computer name and IP from remote computer

4. Help !! How to get the IP or computer name of a caller

5. Getting IP or Computer Name of person viewing page...

6. How determine client IP address, port, and computer name

7. Get Ip address or computer name in ODBC

8. List of all ip addresses and computer names

9. how to get a local computer name and ip

10. Get the computer name from the ip

11. Getting a computer name from a ip address

12. Getting TCP/IP address from computer name

 

 
Powered by phpBB® Forum Software