原帖由 w3528033 于 2008-11-24 22:07 发表
我是说是否能把事先准备好的MAC对应IP和机器名的INI文件的内容集合到BAT里,实现2合1,INI文件内容如下:
NB-101 192.168.0.101 00-E0 ...
这样呢?
- @echo off
- set MASK=255.255.255.0
- set GATEWAY=192.168.0.1
- set DNS=192.168.0.1
- for /f "tokens=12 delims= " %%i in ('ipconfig /all^|find /i "Physical Address"') do set mac=%%i
- for /f "tokens=1,2*" %%i in ('ipconfig /all^|find "Ethernet adapter"') do set Ethernet=%%k
- for /f "tokens=1,2" %%i in ('more /e +13 %0 ^|find /i "%mac:~,-1%"') do set "name=%%i"&set "IP=%%j"
- reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\ComputerName\ActiveComputerName" /v ComputerName /t reg_sz /d %name% /f >nul 2>nul
- reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters" /v "NV Hostname" /t reg_sz /d %name% /f >nul 2>nul
- reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters" /v Hostname /t reg_sz /d %name% /f >nul 2>nul
- netsh interface ip set address "%Ethernet:~,-2%" static %IP% %Mask% %GATEWAY% 1 >nul 2>nul
- netsh interface ip set dns "%Ethernet:~,-2%" static %DNS% >nul 2>nul
- pause&exit
- NB-100 192.168.0.100 00-E0-A0-0C-BD-56
- NB-101 192.168.0.101 00-1A-4D-9C-82-87
- NB-102 192.168.0.102 00-E0-A0-0E-DC-8C
复制代码
|