楼主是想实现机器名和ip批量修改,还是根据输入来修改ip,我实在是没搞太清楚,
以下是根据输入来设置的,只要输入数字,如:10,请楼主自己测试并修改吧:- @echo off&color 1f&mode con cols=50 lines=10
- :set
- cls&echo.&echo.&set /p num=请输入您的计算机序号:
- echo %num%|findstr "[^0-9]">nul&&echo.&&echo 错误输入&&ping /n 2 127.1>nul&&goto set
- reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\ComputerName\ActiveComputerName" /v ComputerName /t reg_sz /d GY%num% /f
- reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters" /v "NV Hostname" /t reg_sz /d GY%num% /f
- reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters" /v Hostname /t reg_sz /d GY%num% /f
- for /f "tokens=2 delims=:" %%i in ('ipconfig /all^|findstr /c:"Host Name"') do set "str=%%i"&call,set "str=%%str:~3%%"
- set /a ip=str+1
- cls&echo.&echo.&echo 设置ip中...
- netsh interface ip set address name="本地连接" source=static addr=192.168.1.%ip%
- mask=255.255.255.0
- cls&echo.&echo.&echo 设置完成&ping /n 3 127.1>nul
复制代码
[ 本帖最后由 batman 于 2008-7-25 15:27 编辑 ] |