这是一个基本的批处理程序,它可以切换本地计算机的 IP 地址。请注意,这个程序假定您的计算机有 5 个预设的 IP 地址,每个 IP 地址都有相同的 DNS 和子网掩码。此外,一个 IP 地址是通过 DHCP 自动获取的。

@echo off set /p choice=Enter the number of the IP address you want to switch to (1-5): if %choice%==1 ( netsh interface ipv4 set address name='Local Area Connection' static 192.168.1.10 255.255.255.0 192.168.1.1 echo IP address switched to 192.168.1.10 ) else if %choice%==2 ( netsh interface ipv4 set address name='Local Area Connection' static 192.168.1.11 255.255.255.0 192.168.1.1 echo IP address switched to 192.168.1.11 ) else if %choice%==3 ( netsh interface ipv4 set address name='Local Area Connection' static 192.168.1.12 255.255.255.0 192.168.1.1 echo IP address switched to 192.168.1.12 ) else if %choice%==4 ( netsh interface ipv4 set address name='Local Area Connection' static 192.168.1.13 255.255.255.0 192.168.1.1 echo IP address switched to 192.168.1.13 ) else if %choice%==5 ( netsh interface ipv4 set address name='Local Area Connection' dhcp echo IP address switched to DHCP ) else ( echo Invalid choice. Please enter a number between 1 and 5. )


原文地址: https://www.cveoy.top/t/topic/nsP7 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录