set 前缀=a
:begin
cls
set 序号=
set /p 序号=输入计算机数字序号:
echo%序号%|findstr "^[0-9][0-9]*$">nul||(echo输入无效&>nul ping -n 3 0&goto :begin)
::设置计算机名,重启后生效
set name=%前缀%%序号%
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
::设置ip
set /a 序号+=20
netsh interface ip set address name="本地连接" source=static addr=192.168.28.%序号% mask=255.255.252.0
netsh interface ip set address name="本地连接" gateway=192.168.28.1 gwmetric=0
netsh interface ip set dns name="本地连接" source=static addr=221.7.128.68 register=PRIMARY
netsh interface ip set wins name="本地连接" source=static addr=114.114.114.114
>nul ping -n 3 0
@echo offset ipaddress=192.168.0.124
set mask=255.255.255.0
set gateway=192.168.0.1
netsh interface ip set address name="以太网" source=static addr=%ipaddress% mask=%mask% gateway=%gateway% 1
netsh interface ip add address name="以太网" addr=192.168.1.124 mask=255.255.255.0 gateway=192.168.1.1 2
pause用可将上面代码中的参数替换成变量.
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)