[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
下面的试试如何
你可以先 SET 你自己需要的
  1. @echo off&Setlocal Enabledelayedexpansion
  2. set "name=youname"
  3. reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\ComputerName\ActiveComputerName" /v ComputerName /t reg_sz /d %name% /f >nul 2>nul
  4. reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters" /v "NV Hostname" /t reg_sz /d %name% /f >nul 2>nul
  5. reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters" /v Hostname /t reg_sz /d %name% /f >nul 2>nul
  6. set IP=192.168.0.2
  7. set MASK=255.255.255.0
  8. set GATEWAY=192.168.0.1
  9. set DNS=192.168.0.1
  10. netsh interface ip set address "本地连接" static %IP% %Mask% %GATEWAY% 1 >nul 2>nul
  11. netsh interface ip set dns "本地连接" static %DNS% >nul 2>nul
  12. pause
复制代码

TOP

原帖由 w3528033 于 2008-11-24 22:07 发表
我是说是否能把事先准备好的MAC对应IP和机器名的INI文件的内容集合到BAT里,实现2合1,INI文件内容如下:
NB-101 192.168.0.101 00-E0 ...

这样呢?
  1. @echo off
  2. set MASK=255.255.255.0
  3. set GATEWAY=192.168.0.1
  4. set DNS=192.168.0.1
  5. for /f "tokens=12 delims= " %%i in ('ipconfig /all^|find /i "Physical Address"') do set mac=%%i
  6. for /f "tokens=1,2*" %%i in ('ipconfig /all^|find "Ethernet adapter"')  do set Ethernet=%%k
  7. for /f "tokens=1,2" %%i in ('more /e +13 %0 ^|find /i "%mac:~,-1%"') do set "name=%%i"&set "IP=%%j"
  8. reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\ComputerName\ActiveComputerName" /v ComputerName /t reg_sz /d %name% /f >nul 2>nul
  9. reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters" /v "NV Hostname" /t reg_sz /d %name% /f >nul 2>nul
  10. reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters" /v Hostname /t reg_sz /d %name% /f >nul 2>nul
  11. netsh interface ip set address "%Ethernet:~,-2%" static %IP% %Mask% %GATEWAY% 1 >nul 2>nul
  12. netsh interface ip set dns "%Ethernet:~,-2%" static %DNS% >nul 2>nul
  13. pause&exit
  14. NB-100 192.168.0.100 00-E0-A0-0C-BD-56
  15. NB-101 192.168.0.101 00-1A-4D-9C-82-87
  16. NB-102 192.168.0.102 00-E0-A0-0E-DC-8C
复制代码
1

评分人数

TOP

返回列表