Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: I want to write a batch file to get the DNS numbers behind a router.


22 Jun 2011   #1

Windows 7 Professional 64bit
 
 
I want to write a batch file to get the DNS numbers behind a router.

I do a lot of internet troubleshooting and would like to put a simple batch file in customers computers that will let me see their DNS numbers when they are using a router.
I currently do this from a command prompt for Comast:

nslookup
set type=ns
comcast.net

It's been years since I wrote a batch file and so I just put these lines in notepad and labeled it dns.bat

However, this just runs the first line, nslookup.
Is there a command that will cause each line to run after Windows has performed the line above?

Or, is there an easier way to do what I want to do?

Thanks in advance!

My System SpecsSystem Spec
.

22 Jun 2011   #2

Windows 7 Ultimate x64 (Retail)
 
 

NSLookup itself pulls up the first server IP of the two servers I have listed.
Would it not be easier to simply open Network and Sharing Center, click Change Adapter Settings, right click on the Local Area Connection and select Properties, select IPv4, click properties?
Note I am using servers I manually entered in.
My System SpecsSystem Spec
22 Jun 2011   #3

win 7 X64 Ultimate SP1
 
 
Set Command

The set command is use to enter a value for a variable. There is no defined variable for "type" that I am aware of. The same goes for your third command listed in your post. Probably that is the problem.
My System SpecsSystem Spec
.


22 Jun 2011   #4

Windows 7 Professional 64bit
 
 

Quote   Quote: Originally Posted by jebuchanan View Post
NSLookup itself pulls up the first server IP of the two servers I have listed.
Would it not be easier to simply open Network and Sharing Center, click Change Adapter Settings, right click on the Local Area Connection and select Properties, select IPv4, click properties?
Note I am using servers I manually entered in.
It just gives me the ip of the router.
And in Adapter Settings I can't see the DNS numbers using DHCP.
My System SpecsSystem Spec
22 Jun 2011   #5

Windows 7 Professional 64bit
 
 

Quote   Quote: Originally Posted by HammerHead View Post
The set command is use to enter a value for a variable. There is no defined variable for "type" that I am aware of. The same goes for your third command listed in your post. Probably that is the problem.
I see.

Any ideas on how to automate the whole procedure?
My System SpecsSystem Spec
22 Jun 2011   #6

Windows 7 Enterprise
 
 

Quote   Quote: Originally Posted by techs View Post
Quote   Quote: Originally Posted by HammerHead View Post
The set command is use to enter a value for a variable. There is no defined variable for "type" that I am aware of. The same goes for your third command listed in your post. Probably that is the problem.
I see.

Any ideas on how to automate the whole procedure?
@Hammerhead, using the 'set' command will create a variable with the value and stores it in volatile memory for the current console session. As soon as you close the console, the variable is cleared and forgotten

@techs, try the command:
nslookup -type=ns comcast.net

For me, it returned:
Code:
Server:  xxxxxxx.aut.ac.nz
Address:  156.62.8.1

Non-authoritative answer:
comcast.net     nameserver = dns101.comcast.net
comcast.net     nameserver = dns103.comcast.net
comcast.net     nameserver = dns102.comcast.net
comcast.net     nameserver = dns105.comcast.net
comcast.net     nameserver = dns104.comcast.net

dns104.comcast.net      internet address = 68.87.68.244
dns104.comcast.net      AAAA IPv6 address = 2001:558:100a:5:68:87:68:244
dns101.comcast.net      internet address = 68.87.29.164
dns101.comcast.net      AAAA IPv6 address = 2001:558:1002:a:68:87:29:164
dns105.comcast.net      internet address = 68.87.72.244
dns105.comcast.net      AAAA IPv6 address = 2001:558:100e:5:68:87:72:244
dns103.comcast.net      internet address = 68.87.76.228
dns103.comcast.net      AAAA IPv6 address = 2001:558:1014:c:68:87:76:228
dns102.comcast.net      internet address = 68.87.85.132
dns102.comcast.net      AAAA IPv6 address = 2001:558:1004:7:68:87:85:132
My System SpecsSystem Spec
23 Jun 2011   #7

win 7 X64 Ultimate SP1
 
 
Good

Xarden:

Thanks for straightening me out.
My System SpecsSystem Spec
23 Jun 2011   #8

Windows 7 Enterprise
 
 

No worries.
Furthermore, the 'setx' command does the same but stores it as a system environment variable. Which you can use in different sessions, or after reboots.
Just be careful that you dont overwrite an existing one, like 'path' for instance.


@Techs,
let us know how that goes for you.
My System SpecsSystem Spec
01 Jul 2011   #9

Windows 7 Professional 64bit
 
 

Quote   Quote: Originally Posted by xarden View Post
No worries.
Furthermore, the 'setx' command does the same but stores it as a system environment variable. Which you can use in different sessions, or after reboots.
Just be careful that you dont overwrite an existing one, like 'path' for instance.


@Techs,
let us know how that goes for you.
Just back from vacation.
I will test and let you know.
thanks!
My System SpecsSystem Spec
01 Jul 2011   #10

Windows 8 Core X64
 
 

I use OpenDNS and doing the following:

ipconfig /all | find "DNS Servers"

returns this:

DNS Servers . . . . . . . . . . . : 208.67.222.222
DNS Servers . . . . . . . . . . . : fec0:0:0:ffff::1%1
DNS Servers . . . . . . . . . . . : 208.67.222.222

It shows both the IPV4 and IPV6 DNS servers available to me.
My System SpecsSystem Spec
Reply

 I want to write a batch file to get the DNS numbers behind a router.




Thread Tools



Similar help and support threads for2: I want to write a batch file to get the DNS numbers behind a router.
Thread Forum
How i write arabic numbers Microsoft Office
Solved How to run a batch file at logoff & some batch scripting help please Backup and Restore
Serial read/write in batch file? General Discussion
Solved How do I write a batch to run a .exe program General Discussion
Solved Batch File that grabs file names from folder to insert into batch file General Discussion
How do I write batch file to delete thousands of files Software

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 06:06 PM.
Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App
  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33