本帖最后由 ArdentMan 于 2011-7-7 12:23 编辑
- @echo off&setlocal enabledelayedexpansion
- echo 正在配置IP地址、DNS请稍候……
- set MASK=255.255.255.0
- set GATEWAY=192.168.1.1
- set DNS1=192.168.1.220
- set DNS2=192.168.1.1
- set WINS=192.168.1.200
- for /f "delims=:" %%i in ('findstr /n "exit$" %~fs0') do set "num=%%i"
- for /f "tokens=1-4" %%a in ('more +%num% %fs0') do set "" %%c"=a"&set "_ %%c=%%a"&set ". %%c=%%b"&set "@ %%c=%%d"
- for /f "tokens=3 delims=: " %%i in ('ipconfig /all^|finstr /c:"Ethernet adapter"') do set "Ethernet=%%i"
- for /f "tokens=2 delims=:" %%i in ('ipconfig /all^|findstr /c:"Physical Address"') do (
- if defined "%%i" (
- wmic computersystem where "name='!_%%i!'" call rename '!@%%i!'
- netsh interface ip set address "%Ethernet%" static !.%%i! %MASK% %GATEWAY%>nul 2>nul
- netsh interface ip set dns "%Ethernet%" static %DNS1% register=PRIMARY>nul 2>nul
- netsh interface ip add dns "%Ethernet%" %DNS2% index=2>nul 2>nul
- netsh interface ip set wins "%Ethernet%" static %WINS%>nul 2>nul
- )
- )
- exit
- PC001 192.168.1.100 00-E0-4C-41-11-A6 祥子
- PC002 192.168.1.101 00-e0-62-0b-1f-6c 郝文婕
- PC003 192.168.1.102 00-e0-62-0b-22-6d 漆浪
- PC004 192.168.1.103 00-e0-66-02-b0-1e 彭雅娜
- PC005 192.168.1.104 00-e0-66-02-f1-c2 李颖诗
- PC006 192.168.1.105 00-e0-66-19-de-e9 陈永行
- PC007 192.168.1.106 00-e0-66-02-f4-15 宁智雄
- PC008 192.168.1.107 00-e0-66-02-b0-1e 彭雅娜
- PC009 192.168.1.108 00-e0-4c-41-11-b3 冯晶晶
- PC010 192.168.1.109 00-e0-66-02-df-8c 周国香
- PC011 192.168.1.110 00-e0-66-02-dd-d8 邓国花
- PC012 192.168.1.111 00-e0-66-0d-71-d9 邱瑾
- PC013 192.168.1.112 00-e0-66-19-de-ea 胡孝龙
复制代码
|