antmar904 Posted January 11, 2018 Share Posted January 11, 2018 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: expandcollapse popup#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 More sharing options...
antmar904 Posted January 11, 2018 Author Share Posted January 11, 2018 (edited) I found out what the issue was. I changed this: FileWriteLine($LogFile, $ComputerNames & "," & $IP) To this: FileWriteLine($LogFile, $ComputerNames[$i] & "," & $IP) If forgot the add the computer name array $ComputerNames[$i] to the filewrite. Edited January 11, 2018 by antmar904 Earthshine 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now