本帖最后由 WHY 于 2019-3-20 15:41 编辑
- @echo off
-
- echo 正在配置IP地址、DNS请稍候……
- set "MASK=255.255.255.0"
- set "GATEWAY=192.168.103.254"
- set "DNS1=202.96.128.143"
- set "DNS2=202.96.128.68"
- set "WINS=192.168.103.254"
-
- for /f "tokens=*" %%i in ('wmic Nic where "NetEnabled='true'" get MacAddress^,NetConnectionID /format:List^|find "="') do set "%%i"
-
- for /f "delims=:" %%i in ('findstr /n /b /e ::::.*:::: "%~f0"') do (
- for /f "tokens=1,2,4" %%i in ('more /e +%%i "%~f0" ^| find /i "%MacAddress::=-%"') do (
- set "name=%%i" & set "IP=%%j" & set "Description=%%k"
- )
- )
-
- if not defined name (
- echo;No such MAC address in the List & pause & exit /b
- ) else if not defined NetConnectionID (
- echo;No Network Connection Found & pause & exit /b
- )
-
- reg add "HKLM\SYSTEM\ControlSet001\Services\lanmanserver\parameters" /v srvcomment /d "%Description%" /f >nul 2>nul
- reg add "HKLM\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters" /v srvcomment /d "%Description%" /f >nul 2>nul
- reg add "HKLM\System\CurrentControlSet\Control\ComputerName\ComputerName" /v ComputerName /d "%name%" /f >nul 2>nul
- reg add "HKLM\System\CurrentControlSet\Services\Tcpip\Parameters" /v "NV Hostname" /d "%name%" /f >nul 2>nul
- reg add "HKLM\System\CurrentControlSet\Services\Tcpip\Parameters" /v Hostname /d "%name%" /f >nul 2>nul
-
- netsh interface ip set address "%NetConnectionID%" static %IP% %Mask% %GATEWAY% 1 >nul 2>nul
- netsh interface ip set dns "%NetConnectionID%" static %DNS1% register=PRIMARY >nul 2>nul
- netsh interface ip add dns "%NetConnectionID%" %DNS2% index=2 >nul 2>nul
- netsh interface ip set wins "%NetConnectionID%" static %WINS% >nul 2>nul
-
- pause & exit /b
-
- :::: Your IP and MAC Addresses Here ::::
- A01 192.168.103.101 10-60-4b-77-fe-a0 北三楼A01
- A02 192.168.103.102 10-60-4b-8b-50-be 北三楼A02
- A03 192.168.103.103 10-60-4b-88-61-7f 北三楼A03
- A04 192.168.103.104 10-60-4b-88-70-a6 北三楼A04
- A05 192.168.103.105 10-60-4B-89-46-CE 北三楼A05
- A06 192.168.103.106 10-60-4b-8b-51-3f 北三楼A06
- A07 192.168.103.107 10-60-4b-8b-53-cd 北三楼A07
- A08 192.168.103.108 10-60-4b-8b-51-38 北三楼A08
- A09 192.168.103.109 10-60-4b-77-e5-c4 北三楼A09
- A10 192.168.103.110 10-60-4b-77-ea-c2 北三楼A10
复制代码 试试吧 |