批处理修改IP地址

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
@echo off
title Change IP Address Tool v3
color 2f
@rem 通过标题检测管理员身份=================================================
 
setlocal EnableDELAYEDEXPANSION
 
set UAC=0
 
For /f "usebackq delims==" %%i In (`tasklist /fi "WINDOWTITLE eq 管理员:  Change IP Address Tool v3"`) Do (
set "cmdline=%%i"
set "cmdline=!cmdline:~0,7!"
if "!cmdline!" == "cmd.exe" (
set UAC=1
)
)
 
if not "%UAC%"=="1" (
echo 请以管理员身份运行
echo 按任意键退出...
pause>nul
exit
)
 
 
@rem 设置需要使用的代理服务器地址===========================================
set ProxyServerValue=127.0.0.1:8087
@rem 无需使用代理服务器的地址,注意:","表示激活无需使用的地址,一定要保留
set ProxyOverrideValue="10.*,"
@rem 这里设置第1个IP的信息==================================================
set MyIP1=192.168.11.222
set MyGateWay1=192.168.11.1
set MyMask1=255.255.255.0
set DNS11=218.85.152.99
set DNS21=218.85.157.99
@rem 这里设置第2个IP的信息==================================================
set MyIP2=192.168.1.222
set MyGateWay2=192.168.1.1
set MyMask2=255.255.255.0
set DNS12=218.85.152.99
set DNS22=218.85.157.99
@rem 这里设置第3个IP的信息==================================================
set MyIP3=2.2.2.22
set MyGateWay3=222.222.222.222
set MyMask3=255.255.255.0
set DNS13=222.222.222.222
set DNS23=222.222.222.221
 
@rem 设置需要测试的IP地址===================================================
  set TestIPc="218.85.152.99"
@rem 设置需要测试的IP地址===================================================
  set TestIPm="222.222.222.222"
@rem 设置需要测试的IP地址===================================================
  set TestIPl="192.168.1.1"
 
@rem 获取网卡名称===========================================================
FOR /F "tokens=2*" %%i IN ('ipconfig/all^|find /i "以太网适配器 "') DO set lanname=%%i
FOR /F "tokens=1* delims=:" %%i in ("%lanname%") do set Lan=%%i
 
FOR /F "tokens=2*" %%i IN ('ipconfig/all^|find /i "无线局域网适配器 "') DO set wlanname=%%i
FOR /F "tokens=1* delims=:" %%i in ("%wlanname%") do set wLan=%%i
 
if not "%Lan%"=="" (if not "%wLan%"=="" (goto :Begin) else (set NetConf="%Lan%"&set confLan=%Lan%&goto :Menu)) else (if not "%wLan%"=="" (set NetConf="%wLan%"&set confLan=%wLan%&goto :Menu) else (echo.&echo 未发现网卡.&echo.&echo 按任意键退出...&pause>nul&exit))
 
:Begin
cls
echo.
echo +------------------------------------------------------------------------------
echo ^|                                                                       
echo ^|                         Change IP Address Tool v1                     
echo ^|                                                                       
echo ^|                             1 %Lan%                                   
echo ^|                             2 %wLan%                                 
echo ^|                                                                      
echo ^|                             Q 退出                                   
echo ^|                                                                      
echo +------------------------------------------------------------------------------
echo.
set /p NetC=请选择需要设置的网络(默认设置-%wLan%):
if "%NetC%"=="1" (if not "%Lan%"=="" (set NetConf="%Lan%"&set confLan=%Lan%&goto :Menu) else (set NetC=&goto :Begin))
if "%NetC%"=="2" (if not "%wLan%"=="" (set NetConf="%wLan%"&set confLan=%wLan%&goto :Menu) else (set NetC=&goto :Begin))
if /i "%NetC%"=="q" exit
if not "%wLan%"=="" (set NetConf="%wLan%"&set confLan=%wLan%&goto :Menu) else (set NetC=&goto :Begin)
 
 
@rem ==============================================================================
:Menu
cls
echo ###############################################################################
echo #                                                                             #
echo #                         Change IP Address Tool v1                           #
echo #                                                                             #
echo #                             1 XM Office                                     #
echo #                             2 192.168.1.222/1                               #
echo #                             3 doobom(2.2.2.22/222)                          #
echo #                                                                             #
echo #                             0 自动获得IP                                    #
echo #                             9 手动设置IP                                    #
echo #                                                                             #
echo #                             P 使用GAE代理                                   #
echo #                             N 不使用代理                                    #
echo #                                                                             #
echo #                             C 测试218.85.152.99                             #
echo #                             M 测试doobom(222.222.222.222)                   #
echo #                             L 测试192.168.1.1                               #
echo #                                                                             #
echo #                             R 选择网卡                                      #
echo #                                                                             #
echo #                             Q 退出                                          #
echo #                                                                             #
echo ###############################################################################
echo.
set /p input=(-%confLan%-)请输入选择的代码[eg:1,H...]:
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%"=="9" goto IP_9
if /i "%input%"=="P" goto IP_P
if /i "%input%"=="n" goto IP_N
if /i "%input%"=="c" set testIP=%TestIPc%&goto IP_C
if /i "%input%"=="m" set testIP=%TestIPm%&goto IP_C
if /i "%input%"=="l" set testIP=%TestIPl%&goto IP_C
if /i "%input%"=="r" set NetC=&set input=&goto Begin
if /i "%input%"=="q" exit
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_9
cls
echo 手动设置%confLan%的IP地址:
set /p MyIP=[ip:192.168.1.22]
if /i "%MyIP%"=="" set MyIP=192.168.1.22
set /p MyMask=[Mask:255.255.255.0]
if /i "%MyMask%"=="" set MyMask=255.255.255.0
set /p MyGateWay=[GateWay:192.168.1.1]
if /i "%MyGateWay%"=="" set MyGateWay=192.168.1.1
set /p DNS1=[DNS1:111.68.8.179]
if /i "%DNS1%"==""  set DNS1=111.68.8.179
set /p DNS2=[DNS2:218.85.152.99]
if /i "%DNS2%"=="" set DNS2=218.85.152.99
goto end
 
@rem ==============================================================================
:IP_P
cls
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
echo 设置代理完成(需重启浏览器)...
pause>nul
set input=
goto :Menu
 
@rem ==============================================================================
:IP_N
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t reg_dword /d 00000000 /f
echo 取消代理完成(需重启浏览器)...
pause>nul
set input=
goto :Menu
 
@rem ==============================================================================
:IP_C
  cls
  ping %testIP%
  pause
  cls
set input=
goto Menu
 
@rem ==============================================================================
:IP_0
cls
echo 正在设置(-%confLan%-)的IP地址:
netsh interface ip set address name=%NetConf% source=dhcp
echo ip:DHCP
netsh interface ip set dns name=%NetConf% source=dhcp
echo.
echo dns:DHCP
echo.
echo 操作完成...
pause>nul
set input=
goto Menu
 
@rem ==============================================================================
:end
cls
echo 正在设置(-%confLan%-)的IP地址:
netsh interface ip set address name=%NetConf% source=static address=%MyIP% mask=%MyMask% gateway=%MyGateWay% gwmetric=0
echo ip:%MyIP%
echo mask:%MyMask%
echo gateway:%MyGateWay%
netsh interface ip set dns %NetConf% static %DNS1% primary
echo.
echo dns1:%DNS1%
netsh interface ip add dns name=%NetConf% address=%DNS2%
echo dns2:%DNS2%
netsh interface ip set wins name=%NetConf% source=static address=none
echo.
echo 操作完成...
pause>nul
set input=
goto Menu