Jump to content

Does TCPNameTOIP only work for internet names?


Recommended Posts

Hi

I have a list of computer names at my company and I want to get their IP addresses but this does not seem to work:

#include <FileConstants.au3>
#include <Array.au3>


HostNameToIPs()

Func HostNameToIPs()

    ; Start the TCP service.
    TCPStartup()

    Local $LogFile = @ScriptDir & "\ComputerNames To IPs.txt"

    Local $File = FileOpenDialog("Select Computer List", "C:\", "Text files (*.txt)")

    MsgBox(0, "Computer List", "The Computer List file that will be used is : " & @CRLF & @CRLF & $File)

    Local $ComputerNames = FileReadToArray($File)

    _ArrayDisplay($ComputerNames)

    Local $hFileOpen = FileOpen($LogFile, 9)

    For $i = 0 To UBound($ComputerNames) - 1
        
        ConsoleWrite("*** " & $ComputerNames[$i] & @CRLF)
        
        Local $IP = TCPNameToIP($ComputerNames[$i])
        ; If an error occurred display the error code and return False.
        If @error Then
            MsgBox($MB_SYSTEMMODAL, "", "Error code: " & @error)
            Return False
        Else
            FileWriteLine($LogFile, $ComputerNames & "," & $IP)
        EndIf

    Next

    FileClose($hFileOpen)

    ; Close the TCP service.
    TCPShutdown()

EndFunc   ;==>HostNameToIPs

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...