Solved Batch file to find ip and host name, and save

June 18, 2009 at 14:11:16
Specs: Windows XP
So I have an odd problem, and a less than easy way of doing it. Our organization has some house keeping that needs to be done, and I would like to use a batch file to aquire ip adress, hostname and dns entries and save them to a txt. Easy enough... :

ipconfig /all > file.txt

However, I would like to run this batch file from a flash drive and keep all of the file.txt's, which is where i run into my problem and question.

What should i include in the batch file to save each file.txt as "Host Name".txt.
I figured something like:

Ipconfig /all > tempIP.txt
Ipconfig /all | Find "Host Name" save as Host
rename tempIP.txt as Host.txt

Pretty simple , but not for someone who hasnt wront a bunch of batch files.

As a little bonus if I could modify the primary and secondary dns entries even more time.

Thanks for any help

See More: Batch file to find ip and host name, and save

Report •

June 18, 2009 at 14:42:54
@echo off
ipconfig /all > tempIP.txt
for /F "tokens=2 delims=:" %%j in ('ipconfig /all ^| find "Host Name"') do set Host=%%j
set Host=%Host:~1%
ren tempIP.txt "%Host%.txt"
:: End_Of_Batch

Sorry but I do not understand your question about DNS.

If you want to explain, please, report exactly the English line you need to modify from ipconfig, as I'm running an Italian Edition of Windows XP.

Report •

June 18, 2009 at 15:25:18
✔ Best Answer
@echo off
ipconfig /all | find "Host Name" > %computername%.txt
ipconfig /all | find "IP Address" >> %computername%.txt
ipconfig /all | find "DNS" >> %computername%.txt

Report •

June 19, 2009 at 07:43:13
In response to IVO

I would like to change the DNS Servers entries also. I can probably figre that part out. However, when i posted i had already gotten frustrated and given up.

Thanks again

Report •

Related Solutions

Ask Question