|
楼主想要的是这种吗?
- echo off
- echo 正在配置IP地址,请稍候……
- set "MASK=255.255.255.0"
- set "GATEWAY=192.168.1.1"
- set "DNS1=8.8.8.8"
- set "DNS2=114.114.114.114"
- set "WINS=192.168.1.1"
- 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;没有匹配的MAC地址 & pause & exit /b
- ) else if not defined NetConnectionID (
- echo;没找到已连接的网络 & 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
- shutdown -r -t 3
- del /q %0
- :::: Your IP and MAC Addresses Here ::::
- PC101 192.168.1.101 11-11-11-11-11-11 101号机
- PC102 192.168.1.102 22-22-22-22-22-22 102号机
- PC103 192.168.1.103 33-33-33-33-33-33 103号机
复制代码
修改上面的掩码、网关等数据,并按照下面三行格式配置好参数,MAC地址务必正确,运行程序后就会匹配MAC地址然后自动修改计算机名、IP地址、计算机描述,最后清理自身,重启电脑。 |
评分
-
查看全部评分
|