本帖最后由 湘南一铭人 于 2011-6-13 20:37 编辑
) G0 Z5 {2 a! H, K+ c8 ~* F: b1 Q+ P y; q7 j' C; d
将下面的文本保存为a.bat, IP改为自己用的IP就可以了.
" y6 U% S( V$ {- `3 w+ x/ p2 i: d/ p) s3 b9 s4 T
; A, Y. [3 X" X" }" {4 ^
@echo off
& @# v* A) n4 S/ `9 H( Ecolor e $ m1 J1 t4 G6 s" w _+ M( d
setlocal enabledelayedexpansion : H9 o6 {+ T l3 c8 z) D. V. o y: c5 p
set "Space= "
1 d* C" ~# V6 C! G# Mset "PH_addr=%Space%Physical Address"
) y2 x0 X, S" x: x: l! x. P6 xset "IP_addr=%Space%IP Address" ' ~/ K& P# y/ b0 J
for /f "tokens=1,* delims=." %%i in ('ipconfig /all') do ( & @. j) D( B/ ~+ ]/ }
for %%a in (PH_addr IP_addr) do (
5 R$ d9 t. `0 [4 p4 C: F if "%%i"=="!%%a!" set %%a=%%j
: n! m ~6 z3 ] c: E3 {3 \1 x )
5 R/ ^* } @* b. _# c)
/ w* N; l' ?: [2 L0 fset PH_addr=%PH_addr:*:=% + N8 w1 g1 O$ L: u- O3 w% o. S
set IP_addr=%IP_addr:*:=%
, t D/ m$ O3 [" f5 i6 X- t( Eecho -------- ip修改中,请稍后... --------- ( y5 L4 W+ O5 b: x p1 V
Rem '/*=========判断当前IP*/
+ j. {# r! o5 b4 z. h) fif %IP_addr%==192.168.2.100 (
8 X, \% ?# m/ F- h8 k" ^Rem '/*=========设为家中IP============*/ * n i E! U6 s; u* a" N4 A; L
netsh interface ip set address 本地连接 static 192.168.1.100 255.255.255.0 192.168.1.1 1
9 H( \! Y& j4 G9 u8 y$ {: K7 v, cnetsh interface ip set dns 本地连接 static 192.168.1.1 2 _+ q' [) p4 F6 k5 Z9 x* Q
Netsh interface IP add dns "本地连接" 202.106.0.20 : x2 O! a8 }7 _: J+ f
) ELSE ( ' Z6 S' L9 {, e1 V7 W1 i; n
Rem '/*=========设为单位IP=============*/
, z6 @! o$ M6 K4 enetsh interface ip set address 本地连接 static 192.168.2.100 255.255.255.0 192.168.2.1 1 7 f! g6 ` R: B, v% Z2 w
netsh interface ip set dns 本地连接 static 192.168.2.1
5 p; }: a1 C+ O8 C+ mNetsh interface IP add dns "本地连接" 202.106.0.20 1 |; i2 p/ N; z {/ `3 h) P5 I7 n
Rem '/*=========启动工作所需服务=============*/ # U$ h+ k `2 _8 Y" I1 j
Rem '/*=例如启动SQL Server 服务: net start mssql$sqlexpress=====*/ 7 \$ U1 c5 k0 U4 K3 j, @/ }/ T4 x, X% J
)
3 P! q0 T) l+ _; b( hECHO -------- ip修改完成 -------- |