IP's from netsh command
Posted: 02 Oct 2009 15:12
Hello All! I have a problem. I need to use primary and secondary DNS servers IPs in cmd script. But how can I get them and assign to corresponding variables? I tried so:
Command
netsh interface ip show dns "Internet"
gives the output:
Configuration for interface "Internet"
Statically Configured DNS Servers: xxx.xxx.xxx.xxx
yyy.yyy.yyy.yyy
Register with which suffix: None
I tried to cut IPs like this:
for /f "skip=2 tokens=5" %%i in ('netsh interface ip show dns "Internet"') do set primary=%%i
result is:
set primary=xxx.xxx.xxx.xxx -correct, but then is overwritten
set primary=None
for /f "skip=3 tokens=1" %%i in ('netsh interface ip show dns "Internet"') do set secondary=%%i
result is:
set secondary=yyy.yyy.yyy.yyy -correct, but then is overwritten
set secondary=Register
How can I tell script not to process the last line
"Register with which suffix: None" ???
Thanks!
Command
netsh interface ip show dns "Internet"
gives the output:
Configuration for interface "Internet"
Statically Configured DNS Servers: xxx.xxx.xxx.xxx
yyy.yyy.yyy.yyy
Register with which suffix: None
I tried to cut IPs like this:
for /f "skip=2 tokens=5" %%i in ('netsh interface ip show dns "Internet"') do set primary=%%i
result is:
set primary=xxx.xxx.xxx.xxx -correct, but then is overwritten
set primary=None
for /f "skip=3 tokens=1" %%i in ('netsh interface ip show dns "Internet"') do set secondary=%%i
result is:
set secondary=yyy.yyy.yyy.yyy -correct, but then is overwritten
set secondary=Register
How can I tell script not to process the last line
"Register with which suffix: None" ???
Thanks!