From 5150feddc642477e00462fc648537af05147a316 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Thu, 1 Feb 2024 01:07:06 +0800 Subject: [PATCH] =?UTF-8?q?windows:=20=E4=BF=AE=E5=A4=8D=20vista/2008=20dn?= =?UTF-8?q?s=20=E6=B2=A1=E6=88=90=E5=8A=9F=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- windows-set-netconf.bat | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/windows-set-netconf.bat b/windows-set-netconf.bat index 4705f0b..e74e154 100644 --- a/windows-set-netconf.bat +++ b/windows-set-netconf.bat @@ -29,7 +29,14 @@ if defined mac_addr ( rem 配置静态 IPv4 DNS 服务器 for %%i in (1, 2) do ( if defined ipv4_dns%%i ( - netsh interface ipv4 add dnsservers !id! !ipv4_dns%%i! %%i no + netsh interface ipv4 add | find "dnsservers" + if ErrorLevel 1 ( + rem vista + netsh interface ipv4 add dnsserver !id! !ipv4_dns%%i! %%i + ) else ( + rem win7 + netsh interface ipv4 add dnsservers !id! !ipv4_dns%%i! %%i no + ) ) ) @@ -42,7 +49,14 @@ if defined mac_addr ( rem 配置 IPv6 DNS 服务器 for %%i in (1, 2) do ( if defined ipv6_dns%%i ( - netsh interface ipv6 add dnsservers !id! !ipv6_dns%%i! %%i no + netsh interface ipv6 add | find "dnsservers" + if ErrorLevel 1 ( + rem vista + netsh interface ipv6 add dnsserver !id! !ipv6_dns%%i! %%i + ) else ( + rem win7 + netsh interface ipv6 add dnsservers !id! !ipv6_dns%%i! %%i no + ) ) ) )