@echo off rem 强制获取管理员权限 %1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit rem //设置变量 set NAME="以太网" rem //可以根据需要更改以下属性值 set ADDR=192.168.1.1 set MASK=255.255.255.0 set GATEWAY=192.168.1.254 set DNS1=59.11.99.66 set DNS2= rem //可以根据需要更改以下属性值 set ADDR_YF=10.0.2.1 set MASK_YF=255.255.255.0 set GATEWAY_YF=10.0.2.254 set DNS1_YF=none set DNS2_YF= rem //以上属性为IP地址、子网掩码、网关、首选DNS和备用DNS echo 当前可用的操作包括: echo 1 设置外网IP echo 2 设置研发网IP echo 3 退出 echo 请选择你要的操作: set /p operate= if %operate%==1 goto 1 if %operate%==2 goto 2 if %operate%==3 goto 3 :1 echo 设置外网IP中, 请稍等... rem //可以根据你的需要进行更改 echo IP_ADDR = %ADDR% echo MASK = %MASK% echo GATEWAY = %GATEWAY% netsh interface ipv4 set address %NAME% static %ADDR% %MASK% %GATEWAY% echo 首选DNS = %DNS1% if "%DNS1%"=="" (echo DNS1为空) else netsh interface ipv4 set dns %NAME% static %DNS1% primary echo 备用DNS = %DNS2% if "%DNS2%"=="" (echo DNS2为空) else (netsh interface ipv4 add dns %NAME% %DNS2%) echo **********设置为外网IP成功:%ADDR%*********** pause goto 3 :2 echo 设置研发网IP中, 请稍等... rem //可以根据你的需要进行更改 echo IP_ADDR = %ADDR_YF% echo MASK = %MASK_YF% echo GATEWAY = %GATEWAY_YF% netsh interface ipv4 set address %NAME% static %ADDR_YF% %MASK_YF% %GATEWAY_YF% echo 首选DNS = %DNS1_YF% if "%DNS1%"=="" (echo DNS1为空) else netsh interface ipv4 set dns %NAME% static %DNS1_YF% primary echo 备用DNS = %DNS2% if "%DNS2%"=="" (echo DNS2为空) else (netsh interface ipv4 add dns %NAME% %DNS2_YF%) echo **********设置研发网IP成功:%ADDR_YF%*********** pause goto 3 :3 exit