本帖最后由 湘南一铭人 于 2011-6-13 20:37 编辑 6 U" S9 |4 l- \% X( ~
1 D1 y( H" x J ?% t将下面的文本保存为a.bat, IP改为自己用的IP就可以了.
: N K1 \/ l: D8 U7 C; a
* T: O7 i# B6 R! P h( w" I
. G. T6 @- D4 _( V8 l, p@echo off
' s1 ~/ V9 i U, \, J) Tcolor e 9 O3 n2 v1 M/ z
setlocal enabledelayedexpansion
# p E- v$ m2 A; c- @set "Space= " ( S3 B: A# h- \" B, }; {5 ?* [
set "PH_addr=%Space%Physical Address" 2 Q C. @1 m# v6 u8 `, Q
set "IP_addr=%Space%IP Address"
5 T# m5 k, v+ ?9 o' y. y9 e2 mfor /f "tokens=1,* delims=." %%i in ('ipconfig /all') do (
- y H# b2 V" h0 D for %%a in (PH_addr IP_addr) do (
5 k( [# z7 ^1 m+ c% V3 i. A if "%%i"=="!%%a!" set %%a=%%j - b `2 O. H' _! v& r
) 5 L% J9 Z2 N5 z% C
)
$ s2 P: n8 c5 `4 x* Iset PH_addr=%PH_addr:*:=%
3 U0 Y9 F8 n1 aset IP_addr=%IP_addr:*:=%
- G- q5 e3 d$ @/ N$ ~echo -------- ip修改中,请稍后... ---------
, j8 h' _* K6 z4 o2 iRem '/*=========判断当前IP*/ 0 Z; T& \9 ]4 O, S
if %IP_addr%==192.168.2.100 ( 7 d& j0 D7 ` m
Rem '/*=========设为家中IP============*/ - w: z5 v. ?. M/ n
netsh interface ip set address 本地连接 static 192.168.1.100 255.255.255.0 192.168.1.1 1 9 V0 y( o# o, u! K6 l( H
netsh interface ip set dns 本地连接 static 192.168.1.1 - q1 K1 y" A+ z, T" A) m
Netsh interface IP add dns "本地连接" 202.106.0.20
r6 x5 y/ [) M) ELSE ( - l9 e3 ]# U8 z0 \4 D8 ~
Rem '/*=========设为单位IP=============*/ " l, G W) ^) i
netsh interface ip set address 本地连接 static 192.168.2.100 255.255.255.0 192.168.2.1 1
7 M: X" |% P. E* _4 Unetsh interface ip set dns 本地连接 static 192.168.2.1 ( K6 K3 `# p4 Q# r: \0 o
Netsh interface IP add dns "本地连接" 202.106.0.20
6 g" Q) W0 P0 ^1 O3 i5 \Rem '/*=========启动工作所需服务=============*/
! s9 y: x7 f7 nRem '/*=例如启动SQL Server 服务: net start mssql$sqlexpress=====*/ ) P2 s" }7 n& E; a/ q1 a9 I$ ~
)
/ o p* q/ L, r1 Y$ U; d0 d" tECHO -------- ip修改完成 -------- |