I have the name of a computer on the network, and I need to know how to get the ip address of said computer from a batch file? Thanks.
52 Answers
Your problem can be solved via command. Like the picture I posted below. You may have mistakenly marked the yellow mark as a MAC address, but they are actually IPv6 addresses. When you use the ping command, you can add "-4" behind the host name to display the IPv4 address.
ping hostname -4 I also have a batch file that returns the hostname and IP address of the computer at the same time. You can write the following code to a txt file and change the extension to .bat. Then double-click the file to get the computer name and ip address. I hope this will help you.
Code:
@echo off title Display your IP and hostname color F9 @echo - for /f "tokens=2 delims=:" %%i in ('ipconfig^|findstr "Address"') do set ip=%%i @echo Your ip address is :%ip% @echo Your computer name is :%COMPUTERNAME% Echo press any key to exit... pause>NUL 0According to this web page (1), you can use the nslookup (2) command to print out some information about a computer including its IP based on its hostname address. You could then filter out only the IP using findstr (3).
