新网创想网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
@echo off
echo.
echo.
echo 自动修改计算机名和ip
echo.
set /p f=请输计算机的IP后缀(值小于255):
set name= test%f%
set net=本地连接 3
set ip=192.168.10.
set mask=255.255.255.0
set gateway=192.168.10.1
set DNS1=114.114.114.114
set dns2=8.8.8.8
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam" /v @ /t REG_SZ /d "%name%" /f >nul
reg add "HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName" /v "ComputerName" /t REG_SZ /d "%name%" /f >nul
reg add "HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName" /v "ComputerName" /t REG_SZ /d "%name%" /f >nul
reg add "HKLM\SYSTEM\CurrentControlSet\Services\Eventlog" /v "ComputerName" /t REG_SZ /d "%name%" /f >nul
reg add "HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName" /v "ComputerName" /t REG_SZ /d "%name%" /f >nul
reg add "HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" /v "NV Hostname" /t REG_SZ /d "%name%" /f >nul
reg add "HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" /v "Hostname" /t REG_SZ /d "%name%" /f >nul
netsh interface ip set address "%net%" static %ip%%f% %mask% %gateway%
netsh interface ip set dns "%net%" static %dns1% primary
netsh interface ip add dns "%net%" %dns2%
echo 已修改的配置信息如下:
echo.
echo 计算机名 %name%
echo ip %ip%%f%
echo 掩码 %mask%
echo 网关 %gateway%
echo dns1 %dns1%
echo dns2 %dns2%
echo.
echo "计算机名和ip修改成功"
pause