使用腳本切換IP

@echo off
title 切換IP

:::::::::::::::::::::::::::::系統設置信息::::::::::::::::::::::::::::::::::
@rem 菜單內容設置:========================================================
set menu1=10.16.252.*
set menu2=備用
set menu3=備用
set menu4=備用
set menu5=備用
set menu6=備用

@rem 設置需要使用的代理服務器地址===========================================
set ProxyServerValue=10.68.200.233:8080
@rem 無需使用代理服務器的地址,注意:",<local>"表示激活無需使用的地址,一定要保留
set ProxyOverrideValue="10.*,<local>"

@rem 這裏設置第1個IP的信息==================================================
set MyIP1=10.16.252.117
set MyGateWay1=10.16.252.1
set MyMask1=255.255.255.0
set DNS11=218.85.152.99
set DNS21=218.85.157.99

@rem 這裏設置第2個IP的信息==================================================
set MyIP2=
set MyGateWay2=
set MyMask2=
set DNS12=
set DNS22=

@rem 這裏設置第3個IP的信息==================================================
set MyIP3=
set MyGateWay3=
set MyMask3=
set DNS13=
set DNS23=

@rem 這裏設置第4個IP的信息==================================================
set MyIP4=
set MyGateWay4=
set MyMask4=
set DNS14=
set DNS24=

@rem 這裏設置第5個IP的信息==================================================
set MyIP5=
set MyGateWay5=
set MyMask5=
set DNS15=
set DNS25=

@rem 這裏設置第6個IP的信息==================================================
set MyIP6=
set MyGateWay6=
set MyMask6=
set DNS16=
set DNS26=

@rem 設置需要更改的網絡連接名稱=============================================
set NetConf="Wireless@Work"


:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::


if "%1%"=="0" goto IP_0
if "%1%"=="1" goto IP_1
if "%1%"=="2" goto IP_2
if "%1%"=="3" goto IP_3
if "%1%"=="4" goto IP_4
if "%1%"=="5" goto IP_5
if "%1%"=="6" goto IP_6
if "%1%"=="C" goto IP_C
if "%1%"=="c" goto IP_C
if "%1%"=="P" goto IP_P
if "%1%"=="p" goto IP_P
if "%1%"=="N" goto IP_N
if "%1%"=="n" goto IP_N
if "%1%"=="192" goto IP_1
if "%1%"=="172" goto IP_2
if "%1%"=="10" goto IP_3

GOTO Menu

@rem ==============================================================================
:Menu
echo.
echo.
echo                            ==================================
echo                                             0:        自動獲得IP
echo                                             1:        %menu1%
echo                                             2:        %menu2%
echo                                             3:        %menu3%
echo                                             4:        %menu4%
echo                                             5:        %menu5%
echo                                             6:        %menu6%
echo                                 ----------------------------
echo                                             C:        查詢IP地址
echo                                             P:        使用IE代理服務器
echo                                             N:        不使用IE代理服務器
echo                                 ----------------------------
echo                                             Q:        退出
echo                            ==================================

set /p input=                                 請輸入選擇的代碼:
if "%input%"=="0" goto IP_0
if "%input%"=="1" goto IP_1
if "%input%"=="2" goto IP_2
if "%input%"=="3" goto IP_3
if "%input%"=="4" goto IP_4
if "%input%"=="5" goto IP_5
if "%input%"=="6" goto IP_6
if "%input%"=="C" goto IP_C
if "%input%"=="c" goto IP_C
if "%input%"=="P" goto IP_P
if "%input%"=="p" goto IP_P
if "%input%"=="N" goto IP_N
if "%input%"=="n" goto IP_N
if "%input%"=="T" goto IP_T
if "%input%"=="t" goto IP_T
if "%input%"=="Q" exit
if "%input%"=="q" exit
cls
goto Menu

@rem ==============================================================================
:IP_1
set MyIP=%MyIP1%
set MyGateWay=%MyGateWay1%
set MyMask=%MyMask1%
set DNS1=%DNS11%
set DNS2=%DNS21%
goto end

@rem ==============================================================================
:IP_2
set MyIP=%MyIP2%
set MyGateWay=%MyGateWay2%
set MyMask=%MyMask2%    
set DNS1=%DNS12%
set DNS2=%DNS22%
goto end

@rem ==============================================================================
:IP_3
set MyIP=%MyIP3%
set MyGateWay=%MyGateWay3%
set MyMask=%MyMask3%    
set DNS1=%DNS13%
set DNS2=%DNS23%
goto end

@rem ==============================================================================
:IP_4
set MyIP=%MyIP4%
set MyGateWay=%MyGateWay4%
set MyMask=%MyMask4%    
set DNS1=%DNS14%
set DNS2=%DNS24%
goto end

@rem ==============================================================================
:IP_5
set MyIP=%MyIP5%
set MyGateWay=%MyGateWay5%
set MyMask=%MyMask5%    
set DNS1=%DNS15%
set DNS2=%DNS25%
goto end

@rem ==============================================================================
:IP_6
set MyIP=%MyIP6%
set MyGateWay=%MyGateWay6%
set MyMask=%MyMask6%    
set DNS1=%DNS16%
set DNS2=%DNS26%
goto end

@rem ==============================================================================
:IP_C
ipconfig /all
pause
exit

@rem ==============================================================================
:IP_P
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /t reg_sz /d %ProxyServerValue% /f
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyOverride /t reg_sz /d %ProxyOverrideValue% /f
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t reg_dword /d 00000001 /f
exit

@rem ==============================================================================
:IP_N
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t reg_dword /d 00000000 /f
exit

@rem ==============================================================================
:IP_0
netsh interface ip set address %NetConf% dhcp
netsh interface ip set dns %NetConf% dhcp
exit

@rem ==============================================================================
:end
netsh interface ip set address %NetConf% static %MyIP% %MyMask% %MyGateWay% 0
netsh interface ip set dns %NetConf% static %DNS1% primary
exit
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章