脚本1
@echo off
for /f "tokens=2 delims==" %%a in ('wmic nic where "NetConnectionStatus=2 and NetEnabled=1" get NetConnectionID /format:list') do set connectionName=%%a
:: Configuration Variables ::
set primaryDNS=1.1.1.1
set alternateDNS=2.2.2.2
:: Change Nothing Below This Line ::
netsh int ip delete dns %connectionName% all
netsh int ip set dns %connectionName% static %primaryDNS% primary
netsh int ip add dns name=%connectionName% %alternateDNS% index=2
pause
脚本2
@echo off
for /f "tokens=4*" %%a in ('netsh interface show interface ^| findstr "已连接"') do set "connectionName=%%a%%b"
:: Configuration Variables ::
set primaryDNS=1.1.1.1
set alternateDNS=2.2.2.2
:: Change Nothing Below This Line ::
netsh int ip delete dns %connectionName% all
netsh int ip set dns %connectionName% static %primaryDNS% primary
netsh int ip add dns name=%connectionName% %alternateDNS% index=2
pause
Others
C:\> WMIC NICCONFIG WHERE "IPEnabled=TRUE AND IPConnectionMetric > 0" GET * /FORMAT:LIST
C:\> WMIC NICCONFIG WHERE "IPEnabled=TRUE AND IPConnectionMetric > 0" GET DNSHostName, IPAddress, IPSubnet, DefaultIPGateway, DNSServerSearchOrder, MACAddress
C:\> WMIC NICCONFIG WHERE "IPEnabled=TRUE AND IPConnectionMetric > 0" GET DNSHostName, IPAddress, IPSubnet, DefaultIPGateway, DNSServerSearchOrder, MACAddress /FORMAT:LIST
Definitely, what a great blog and revealing posts, I definitely will bookmark your site. Best Regards! Kelila Bordy Palm
Thank you for your high comment. I will continue to share more knowledge with you.
RIP Wally. You were one of a kind with your sense of humor and dedication to your family. You will be missed. Ginni Clifford Countess
Ha ha, thank you, thank you, you are very humorous too.
My family always say that I am wasting my time here
at net, however I know I am getting know-how daily by
reading thes nice content.
You are a wonderful person.
We’re a group of volunteers and opening a new scheme in our community.
Your website offered us with valuable information to work on. You have done an impressive
job and our entire community will be thankful to you.
You are welcome.I hope we can learn from each other, make progress together in the future.
That is really attention-grabbing, You are an excessively
professional blogger. I’ve joined your rss feed and stay up for seeking more of your fantastic post.
Also, I’ve shared your site in my social networks
Haha…Thank you very much for sharing. Progress together.
Howdy! I simply wish to offer you a huge thumbs up for your great info you have
got here on this post. I’ll be returning to your web site for more soon.
Ha ha, thank you for your praise, welcome to come back often.
Wow, marvelous weblog structure! How lengthy have you ever been running a blog for?
you made running a blog look easy. The total glance of
your web site is wonderful, let alone the content!
That’s because you’re great, too, so you can find the charm of my blog