本帖最后由 湘南一铭人 于 2011-6-13 20:37 编辑 7 V# J U7 L+ y1 N( _) |
( n+ M% }0 P5 s
将下面的文本保存为a.bat, IP改为自己用的IP就可以了. j* o p& q: I' }
; a% l* I0 f5 n: Z
* I6 w! J, f% l5 a1 o& A@echo off 3 H, ]/ g' H% J8 | z1 R
color e 3 t( G1 r* a2 e. @/ T5 d
setlocal enabledelayedexpansion
a, l& ], `9 t/ }1 k! T# rset "Space= "
4 G0 P6 }* I" d2 V, }1 ~set "PH_addr=%Space%Physical Address"
# E x: w+ f! t7 X" n& a) Fset "IP_addr=%Space%IP Address" % }7 n3 H6 f5 L, w) x) B8 q7 x
for /f "tokens=1,* delims=." %%i in ('ipconfig /all') do (
4 @) h" k$ n, D& J1 d& ^" w for %%a in (PH_addr IP_addr) do (
1 A/ c! T. J$ }0 k! f0 U& d* F if "%%i"=="!%%a!" set %%a=%%j
6 U7 Q2 k( U. q1 z8 E0 X4 a V& y )
. D6 G1 E! ^/ I5 L5 E6 h" R D)
! K. S3 P8 _& _( y$ B0 c8 zset PH_addr=%PH_addr:*:=%
" _) e) j, i4 G# @8 Rset IP_addr=%IP_addr:*:=% 8 Z2 Z" m( ~8 i8 a( z4 }+ P
echo -------- ip修改中,请稍后... --------- 2 ?. A4 }6 o! q6 I
Rem '/*=========判断当前IP*/ 3 S$ m- Z7 f: R; S1 T/ g7 q; _. h
if %IP_addr%==192.168.2.100 (
' V5 o% ^7 @9 hRem '/*=========设为家中IP============*/ ) v' N( ~7 }7 t, ^) B# W
netsh interface ip set address 本地连接 static 192.168.1.100 255.255.255.0 192.168.1.1 1 . R4 I3 [- D2 X5 s7 u
netsh interface ip set dns 本地连接 static 192.168.1.1
0 W3 X% `& e6 F, H6 ?Netsh interface IP add dns "本地连接" 202.106.0.20
! f0 Y1 u% T O) s9 Y5 h3 i) ELSE ( . s. J# Q! L9 j4 v, ?
Rem '/*=========设为单位IP=============*/ 8 \4 x3 \5 s. k% c5 M4 B/ Q- C+ U% ^
netsh interface ip set address 本地连接 static 192.168.2.100 255.255.255.0 192.168.2.1 1
X/ I V' n. K* k9 D9 qnetsh interface ip set dns 本地连接 static 192.168.2.1
2 M; X8 A* T3 `/ E; ~Netsh interface IP add dns "本地连接" 202.106.0.20
+ b3 _' Q2 ]5 G; QRem '/*=========启动工作所需服务=============*/ - b) R3 R1 W% H% ^
Rem '/*=例如启动SQL Server 服务: net start mssql$sqlexpress=====*/
# n3 D, D- \5 H* K8 h)
+ Z2 O U; D4 b% V/ i# ~ECHO -------- ip修改完成 -------- |