提示输入密码:r bw
代码如下:
@echo off:begin1
set /p password=请输入密码:
if not "%password%"=="r bw" echo 密码不对 & goto begin1
set MASK=255.255.255.0
set gateway=172.16.1.1
set newwg=rbw
:begin
set /p hao=请输入1-154之间的整数:
echo %hao%|findstr ^^[-,0-9]*[0-9]^$
if errorlevel 1 cls & echo 非整数,请重新输入 & goto begin
if %hao% lss 1 cls & echo 上机号太小,请重新输入 & goto begin
if %hao% gtr 154 cls & echo 上机号太大,请重新输入 & goto begin
cls
set computername=s%hao%
set /a ipx=%hao%+100
set ip=172.16.1.%ipx%
set dns1=202.102.152.3
set dns2=219.218.80.66
echo.
echo 正在更改计算机名请稍后......
echo.
reg add HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName /v ComputerName /t REG_SZ /d %computername% /f > nul
reg add HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName /v ComputerName /t REG_SZ /d %computername% /f > nul
reg add HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters /v Hostname /t REG_SZ /d %computername% /f > nul
reg add HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters /v "NV Hostname" /t REG_SZ /d %computername% /f > nul
echo.
echo 正在更改计算机名⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯
wmic computersystem where Name="%COMPUTERNAME%" call JoinDomainOrWorkgroup Name="%newwg%"
echo.
echo 正在更改IP请稍后......
echo.
echo IP地址及子网掩码设置完成
netsh interface ip set address name="本地连接" source=static addr=%IP% mask=%MASK%
echo 网关地址设置完成
netsh interface ip set address name="本地连接" gateway=%GATEWAY% gwmetric=0
rem echo 主DNS地址设置完成
netsh interface ip set dns name="本地连接" source=static addr=%DNS1% register=PRIMARY
rem echo 第二DNS地址设置完成
netsh interface ip add dns name="本地连接" addr=%DNS2% index=2
echo 重启电脑,按任意键继续,不想重新,直接关闭该程序⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯ & pause>nul
rem 删除最后一行的rem
rem %systemroot%\system32\iisreset.exe /reboot /timeout:0
shutdown -r -t 0