批处理按编号一键设置计算机名称IP地址改完即刻生效不用重起电脑

时间:2022-07-29 14:55:17 阅读: 最新文章 文档下载
说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。
@echo off&setlocal ENABLEDELAYEDEXPANSION mode con: cols=50 lines=20 color 1f

title 输入电脑编号自动改IP\计算机名等不用重启电脑 @echo 机号前缀/IP/子网/网关/DNS set TimeAll=10 cls :menu set pc=LH

set ip=192.168.0.

set mask=255.255.255.0 set gateway=192.168.0.253 set dns1=202.96.128.166 set dns2=202.96.128.86 ::set dns2=202.96.128.86 @echo 请输入您要修改的机号:

set /p name= %pc% set a=!name:~-2! set b=!name:~-1! set h=!name:~,-2! set g=!a:~,-1! set iip=!name!

if %name% geq 100 set iiip=!name!&goto aaa

if %g%==0 set iiip=!b!&goto aaa if %h%==0 set iiip=!a!&goto aaa set iiip=!name! :aaa

for /l %%c in (1,1,9) do ( set d=00%%c

if !name!==!d! goto OK ) cls

for /l %%c in (10,1,99) do ( set d=0%%c echo !d!

if !name!==!d! goto OK ) cls

for /l %%c in (100,1,254) do ( set d=%%c echo !d!


if !name!==!d! goto OK ) cls

@echo 输入有错误请重新输入 goto menu :OK

@reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName" /v ComputerName /t reg_sz /d !pc!%name% /f

@reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters" /v "NV Hostname" /t reg_sz /d !pc!%name% /f

@reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters" /v Hostname /t reg_sz /d !pc!%name% /f cls

FOR /F "tokens=2*" %%i in ('ipconfig/all^|find /i "Ethernet adapter "') DO set ETname=%%j FOR /F "tokens=1* delims=:" %%E in ("%ETname%") do set ehter=%%E

FOR /F "tokens=12*" %%c in ('ipconfig/all^|find /i "Physical Address"') DO set mac=%%c

@echo 网络属性:%ehter% @echo 网络地址:%mac%

@echo ………………………………………………………………… @echo 计算机:!pc!%name% @echo IP地址:%ip%%iiip% @echo 网:!mask! @echo 关:!gateway! @echo DNS%dns1% @Echo DNS%dns2%

@echo ………………………………………………………………… @echo 配置你的IP地址.请稍等……

netsh interface ip set address name="%ehter%" source=static addr=192.168.0.%iiip% mask=!mask! gateway=%gateway% gwmetric=0

netsh interface ip set dns name="%ehter%" source=static addr=%dns1% register=PRIMARY netsh interface ip add dns name="%ehter%" addr=%dns2%

netsh interface ip set wins name="%ehter%" source=static addr=none :time cls

@echo 配置完成

@echo 网络属性:%ehter% @echo 网络地址:%mac%


@echo ================================================== @echo 计算机:!pc!%name% @echo IP地址:%ip%%iiip% @echo 网:!mask! @echo 关:!gateway! @echo DNS%dns1%

@Echo DNS%dns2% @Echo

@Echo 领航网络--umin制作

@echo ==================================================

set /a h+=1

set /a time1=%TimeAll%-%h%

set "c=257abcdef"

set /a d=%random%%%8+1 color 1!c:~%d%,1!

@echo %time1%秒后自动安装“网维大师”还原 ping -n 2 127.0.0.1 >nul

if %time1%=="0" goto bbb if %time1% gtr 0 goto time :bbb

@ECHO 正在安装系统还原...... E:\NBMSClient\ClientSetup.exe /y ::regedit /s run.reg ::ProtectedC.exe ::Protected*.exe

ping 127.0.0.1 -n 3 >nul

::rehy -SETHY -SETREBOOT


本文来源:https://www.wddqw.com/doc/ef519335f9d6195f312b3169a45177232f60e480.html