Script to resolve hostnames to IP address
RESOLVER – Script to resolve a list of hostnames to their IP addresses
This script will translate a list of IP addresses from a .txt file, in columns to a .csv file in the same directory as the script resides, of course you can edit the code as you like.
Here is the code:
@echo
setlocal enabledelayedexpansion
set input=computerlist.txt
set output=computerlist.csv
for /F %%G in ('type "%input%"') do (
set ip=
for /F "tokens=* skip=2" %%H in ('nslookup %%G 2^>NUL') do (
set line=%%H
if "!line:~0,8!"=="Address:" set ip=!line:~10!
if "!line:~0,10!"=="Addresses:" set ip=!line:~12!
)
echo %%G,!ip!>>"%output%"
)
To make it work you need to create a .cmd file with this code and save it into a folder.
In the same directory you need to create a file named computerlist.txt where there are all the hostnames to be translated.
The rest is just double click the .cmd file and in the same folder will be created a file computerlist.csv.
If you don’t want to see the “many things” on the “black window”, you can turn off the echo, just changing the code from @echo to @echo off
Regards
Any question? You need our FAST help? Go to our forum and as for FREE!

Translator

Recent Virus Threats
Subscribe to our feed
Recent Posts
- AV Security Essentials Virus
- Security Shield Virus
- Smart Anti-Malware Protection Virus
- Internet Security Virus
- Antivirus Smart Protection
- Malware Protection Center Virus
- Smart Protection 2012 Virus
- Internet Security 2012 Virus
- Remove Internet Security Guard
- Internet Security Guard Virus
- Win 7 Internet security 2012 Virus
- Vista Home Security 2012 Virus
- Vista Antivirus 2012
- Vista Anti-Spyware 2012
- XP Anti-Spyware 2012
Forums
Recognition Wall



