快速切换IP的批处理!
批处理内容如下:
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 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 |
@echo?off color?1A Title?[SMART专用?IP设置V1.0] cls echo. echo?SMART专用?IP设置V1.0?????%date%%time% echo. @ipconfig?/all?>?c:\ipconRt.txt for?/f?"tokens=1,2*?delims=:"?%%i?in?('findstr?/NIC:"Description"?c:\ipconRt.txt')?do?( echo?网卡描述:%%k goto?netaddress ) :netaddress for?/f?"tokens=1,2*?delims=:"?%%i?in?('findstr?/NIC:"IP?Address"?c:\ipconRt.txt')?do?( echo???IP地址:%%k goto?gateway ) :gateway for?/f?"tokens=1,2*?delims=:"?%%i?in?('findstr?/NIC:"Gateway"?c:\ipconRt.txt')?do?( echo?网关地址:%%k goto?mask ) :mask for?/f?"tokens=1,2*?delims=:"?%%i?in?('findstr?/NIC:"Mask"?c:\ipconRt.txt')?do?( echo?子网掩码:%%k goto?dns ) :dns for?/f?"tokens=1,2*?delims=:"?%%i?in?('findstr?/NIC:"DNS?Servers"?c:\ipconRt.txt')?do?( echo?DNS地址:%%k goto?mac ) :mac for?/f?"tokens=1,2*?delims=:"?%%i?in?('findstr?/NIC:"Physical?Address"?c:\ipconRt.txt')?do?( echo?物理地址:%%k goto?dispE ) :dispE echo. del?c:\ipconRt.txt echo?****************************** echo?*?本脚本由Major提供,欢迎使用?* echo?*?--------------------------?*? echo?*????????????????????????????*? echo?*???????1)无限制16.179_IP????*? echo?*???????2)高速10.140_IP??????* echo?*???????3)自动获取???????????* echo?*???????4)手动设置???????????* echo?*???Enter)退出???????????????* echo?****************************** echo. :START set???VAR= set/p?VAR=请选择网络[1,2,3,4,Enter]进行切换: if?"%VAR%"=="1"?goto?school if?"%VAR%"=="2"?goto?home if?"%VAR%"=="3"?goto?auto if?"%VAR%"=="4"?goto?manul if?"%VAR%"==""?goto?exit goto?end :exit echo. rem?@ipconfig echo?保留当前配置。 goto?end :school echo. echo?正在处理中,请稍候... echo. @netsh?interface?ip?set?address?"本地连接"?static?192.168.16.179?255.255.255.0?192.168.16.1?>NUL @netsh?interface?ip?set?dns?"本地连接"?static?202.96.128.86?>NUL @netsh?interface?ip?add?dns?"本地连接"?202.96.128.166 goto?end :home echo. echo?正在处理中,请稍候... echo. @netsh?interface?ip?set?address?"本地连接"?static?192.168.10.140?255.255.255.0?192.168.10.1?>NUL @netsh?interface?ip?set?dns?"本地连接"?static?202.96.128.86?>NUL @netsh?interface?ip?add?dns?"本地连接"?202.96.128.166 goto?end :auto echo. echo?正在处理中,请稍候... echo. @netsh?interface?ip?set?address?"本地连接"?dhcp?>NUL @netsh?interface?ip?set?dns?"本地连接"?dhcp?>NUL @echo?网络地址:?自动获取 goto?end :manul echo. set???VAR1= set/p?VAR1=请输入IP地址: echo. if?"%VAR1%"==""?goto?setGATEWAY echo?正在处理中,请稍候... echo. @netsh?interface?ip?set?address?"本地连接"?static?addr=%VAR1%?mask=255.255.255.0?>NUL @echo???IP地址:?%VAR1% @echo. :setGATEWAY set???VAR2= set/p?VAR2=请输入网关地址: echo. if?"%VAR2%"==""?goto?setDNS echo?正在处理中,请稍候... echo. @netsh?interface?ip?set?address?"本地连接"?static?gateway=%VAR2%?gwmetric=1?>NUL @echo???网关地址:?%VAR2% @echo. :setDNS set???VAR3= set/p?VAR3=请输入DNS地址: echo. if?"%VAR3%"==""?goto?START echo?正在处理中,请稍候... echo. @netsh?interface?ip?set?dns?"本地连接"?static?addr=%VAR3%?register=PRIMARY?>NUL @echo???DNS地址:?%VAR3% @echo. :end @echo. @ipconfig?/all?>?c:\ipconRt.txt :netaddress for?/f?"tokens=1,2*?delims=:"?%%i?in?('findstr?/NIC:"IP?Address"?c:\ipconRt.txt')?do?( echo???IP地址:%%k goto?gateway ) :gateway for?/f?"tokens=1,2*?delims=:"?%%i?in?('findstr?/NIC:"Gateway"?c:\ipconRt.txt')?do?( echo?网关地址:%%k goto?mask ) :mask for?/f?"tokens=1,2*?delims=:"?%%i?in?('findstr?/NIC:"Mask"?c:\ipconRt.txt')?do?( echo?子网掩码:%%k goto?dns ) :dns for?/f?"tokens=1,2*?delims=:"?%%i?in?('findstr?/NIC:"DNS?Servers"?c:\ipconRt.txt')?do?( echo?DNS地址:%%k goto?dispE ) :dispE echo. del?c:\ipconRt.txt echo?处理完成,谢谢使用! echo. pause |
请将文本保存为?.bat?或?.cmd的格式
【注】本文仅作为原理参考!!!???大家可以根据自己的情况来修改IP,请将里面的IP改为你自己需要的!
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????By:Colin(刘飞)