Computing.Net > Forums > Programming > Batch file to find ip and host name, and save

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch file to find ip and host name, and save

Reply to Message Icon

Name: I.T. R.Simon
Date: June 18, 2009 at 14:11:16 Pacific
OS: Windows XP
Subcategory: Batch
Comment:

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



Sponsored Link
Ads by Google

Response Number 1
Name: IVO
Date: June 18, 2009 at 14:42:54 Pacific
Reply:

@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.


0

Response Number 2
Name: tonysathre
Date: June 18, 2009 at 15:25:18 Pacific
Reply:

@echo off
ipconfig /all | find "Host Name" > %computername%.txt
ipconfig /all | find "IP Address" >> %computername%.txt
ipconfig /all | find "DNS" >> %computername%.txt


0

Response Number 3
Name: I.T. R.Simon
Date: June 19, 2009 at 07:43:13 Pacific
Reply:

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


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch file to find ip and host name, and save

Batch File to find files www.computing.net/answers/programming/batch-file-to-find-files/17076.html

batch file to find and copy www.computing.net/answers/programming/batch-file-to-find-and-copy/9236.html

Batch File to find directory and co www.computing.net/answers/programming/batch-file-to-find-directory-and-co/15664.html