我希望编写一个批处理文件,该文件采用当前的 IP/子网/网关/DNS 并对其进行静态设置(XP 及更高版本)。即使它已经是静态的,我在网上找到了一个脚本,但我需要找到当前 IP 信息的部分。如果适配器总是被命名为“本地连接”我会很好,但不是。任何人都可以帮忙吗?
@ECHO OFF
set varip=
set varsm=
set vargw=
set vardns1=
set vardns2=
set varhome=
ECHO Setting IP Address and Subnet Mask
netsh int ip set address name = "Local Area Connection" source = static addr = %varip% mask = %varsm%
ECHO Setting Gateway
netsh int ip set address name = "Local Area Connection" gateway = %vargw% gwmetric = 1
ECHO Setting Primary DNS
netsh int ip set dns name = "Local Area Connection" source = static addr = %vardns1%
ECHO Setting Secondary DNS
netsh int ip add dns name = "Local Area Connection" addr = %vardns2%
rem ECHO Here are the new settings for %computername%:
rem netsh int ip show config
pause
谢谢,
埃里克