Echo off
%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit
Echo off
cls
echo ******正在设置 IP地址******
Netsh interface IP Set address "以太网" Static 172.16.1.222 255.255.255.0 172.16.1.1 1
echo ******正在设置DNS地址******
Netsh interface IP Set dns name="以太网" source=dhcp
Echo ******O K 设 置 成 功******
Echo.
Echo ******172.16.1.222******
Echo.
Echo ******按 任意键 退出******
Echo.
Pause
例子2:设置DHCP自动获取IP
Echo off
%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit
Echo off
cls
echo ******正在设置 IP地址******
Netsh interface IP set address name="以太网" source=dhcp
echo ******正在设置DNS地址******
Netsh interface IP Set dns name="以太网" source=dhcp
Echo ******O K 设 置 成 功******
Echo.
Echo ******地址为自动获取******
Echo.
Echo ******按 任意键 退出******
Echo.
Pause
设置DHCP后,打开网络连接可能会出现IP地址没有变为DHCP的情况。可以重启后进行尝试。