码迷,mamicode.com
首页 > Web开发 > 详细

B606 ChangeNet

时间:2016-04-13 18:46:23      阅读:232      评论:0      收藏:0      [点我收藏+]

标签:

技术分享
 1 @echo off
 2 Setlocal Enabledelayedexpansion
 3 title B606 ChangeNet
 4 
 5 for /f "delims=" %%i in (‘ipconfig ^| findstr /c:"192.168.208"‘) do set inside=t
 6 for /f "delims=" %%i in (‘ipconfig ^| findstr /c:"172.16.35"‘) do set outside=t
 7 
 8 for /f "delims=" %%i in (‘ipconfig ^| findstr /c:"IPv4"‘) do (
 9 set tmp=%%i
10 rem ipld is meaning ipv4 last digit
11 if "!tmp:~-2,1!" EQU "." set ipld=!tmp:~-1,1!
12 if "!tmp:~-3,1!" EQU "." set ipld=!tmp:~-2,2!
13 if "!tmp:~-4,1!" EQU "." set ipld=!tmp:~-3,3!
14 if "!ipld!" EQU "" set ipld=253
15 )
16 
17 if "%inside%" EQU "t" netsh interface ip set address name="本地连接" source=static 172.16.35.%ipld% 255.255.255.0 172.16.35.254 1 >nul 2>nul && set setip=t
18 if "%outside%" EQU "t" netsh interface ip set address name="本地连接" source=static 192.168.208.%ipld% 255.255.255.0 192.168.208.254 1 >nul 2>nul && set setip=t
19 if "%setip%" EQU "" netsh interface ip set address name="本地连接" source=static 192.168.208.%ipld% 255.255.255.0 192.168.208.254 1 >nul 2>nul && set setip=t
20 
21 netsh interface ip set dns "本地连接" static 114.114.114.114 primary >nul 2>nul
22 netsh interface ip add dns "本地连接" 114.114.115.115 >nul 2>nul
23 
24 if "%inside%|%outside%" EQU "t|" set output=Inside To Outside
25 if "%inside%|%outside%" EQU "|t" set output=Outside To Inside
26 if "%inside%|%outside%" EQU "|" set output=UnKnow To Inside
27 if "%setip%" EQU "t" (color 0A && set setip=Succeed) else (color 0C && set setip=Failed)
28 
29 echo %output% %setip% && pause > nul
View Code

 

B606 ChangeNet

标签:

原文地址:http://www.cnblogs.com/gwsbhqt/p/5387838.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!