win 8(win 7)批处理设置IP

适合所有经常更改IP的朋友,里面的内容可用可用根据自己的需要随意修改


@rem 根据自己的需要修改带 (@rem/注释)的地方,修改完毕后直接将本文件后缀名.txt改为.bat即可使用
@rem 运行 : 右键菜单-〉以管理员身份运行
@echo off
title --IP自动设置 -- 
MODE con: COLS=80 lines=30
color 0a

:menu
cls

echo ----------------------------------
echo       请选择,输入数字按回车
echo ----------------------------------
echo.
echo       设置为公司用IP 请按 1
echo       设置为自动获取 请按 2
echo       设置IE代理     请按 3
echo       清除IE代理     请按 4
echo       查看当前IP     请按 5
echo       退出           请按 6
echo.

set /p choice=      您的选择:

echo.

if "%choice%"=="1" goto ip1
if "%choice%"=="2" goto ip2
if "%choice%"=="3" goto ie3
if "%choice%"=="4" goto ie4
if "%choice%"=="5" goto ip5
if "%choice%"=="6" goto end

goto menu

:ip1
echo 公司IP自动设置开始....
@rem  win7:INTERFACE=本地连接   win8:INTERFACE=以太网
@set INTERFACE=以太网
@rem  以下地址是无效的,请根据自己实际IP而更改
@set IP=192.168.144.101
@set MASK=255.255.255.0
@set GATEWAY=192.168.144.131
@set IP2=172.28.88.131
@set MASK2=255.255.255.0
@set GATEWAY2=192.168.144.254
@set DNS1=192.168.181.10
@set DNS2=192.168.12.3

netsh interface ip set address "%INTERFACE%" static %IP% %MASK% %GATEWAY% 0
netsh interface ip add address "%INTERFACE%" %IP2% %MASK2% %GATEWAY2% 0
netsh interface ip set dns "%INTERFACE%" static %DNS1% PRIMARY
netsh interface ip add dns "%INTERFACE%" %DNS2% index=2

@echo 设置完毕,自动退出!
exit



:ip2
echo IP自动设置开始....
echo.
echo 自动获取IP地址....
@rem  win7: name="本地连接"   win8: name = "以太网"
netsh interface ip set address name = "以太网" source = dhcp
echo 自动获取DNS服务器....
netsh interface ip set dns name = "以太网" source = dhcp 
@echo 设置完毕,自动退出!
exit

:ie3
@echo off 
echo 开始设置IE代理上网 
@rem 172.88.28.10:80 修改为自己要设置的代理以及端口
reg add "HKCUSoftwareMicrosoftWindowsCurrentVersionInternet Settings" /v ProxyEnable /t REG_DWORD /d 1 /f 
reg add "HKCUSoftwareMicrosoftWindowsCurrentVersionInternet Settings" /v ProxyServer /d "172.88.28.10:80" /f  
@echo 设置代理完毕,自动退出!
exit

:ie4
@echo off 
echo 开始清除IE代理设置 
reg add "HKCUSoftwareMicrosoftWindowsCurrentVersionInternet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f 
reg add "HKCUSoftwareMicrosoftWindowsCurrentVersionInternet Settings" /v ProxyServer /d "" /f 
echo IE代理清除完毕,自动退出! 
exit


:ip5
@echo off
cls
color 0A
ipconfig /all
pause >nul
goto menu
 

 


原文地址:https://www.cnblogs.com/pangblog/p/3249419.html