计算机专家 演示一个 批处理 程序 用于切换本地的5个预先保存在 批处理里面的不通网段的IP地址 但有相同的dns 和子网掩码。和一个通过dhcp 自动获取的方式 并且在 退出前显示 设置好的 ip
@echo off REM 设置变量 set ip1=192.168.0.1 set ip2=192.168.1.1 set ip3=192.168.2.1 set ip4=192.168.3.1 set ip5=192.168.4.1
REM 显示菜单 echo 请选择要切换的IP地址: echo 1. %ip1% echo 2. %ip2% echo 3. %ip3% echo 4. %ip4% echo 5. %ip5% echo 6. 自动获取IP地址 set /p choice=输入菜单编号:
REM 执行命令 if "%choice%"=="1" ( netsh interface ipv4 set address name="本地连接" static %ip1% 255.255.255.0 192.168.0.1 ) else if "%choice%"=="2" ( netsh interface ipv4 set address name="本地连接" static %ip2% 255.255.255.0 192.168.1.1 ) else if "%choice%"=="3" ( netsh interface ipv4 set address name="本地连接" static %ip3% 255.255.255.0 192.168.2.1 ) else if "%choice%"=="4" ( netsh interface ipv4 set address name="本地连接" static %ip4% 255.255.255.0 192.168.3.1 ) else if "%choice%"=="5" ( netsh interface ipv4 set address name="本地连接" static %ip5% 255.255.255.0 192.168.4.1 ) else if "%choice%"=="6" ( netsh interface ipv4 set address name="本地连接" dhcp ) else ( echo 无效的菜单编号! pause exit )
REM 显示设置的IP地址信息 echo. echo 当前IP地址信息: ipconfig | findstr IPv4 echo. paus
原文地址: https://www.cveoy.top/t/topic/ciNS 著作权归作者所有。请勿转载和采集!