>

window批处理修改计算机名,自动修改计算机名

- 编辑:澳门新葡亰平台游戏 -

window批处理修改计算机名,自动修改计算机名

一、需要重启

@echo off  
echo     修改计算机器名... 
set pcname=WinXP-%random:~-3% 
echo Windows Registry Editor Version 5.00>ComputerName.reg 
echo [HKEY_CURRENT_USERSoftwareMicrosoftWindowsShellNoRoam]>>ComputerName.reg 
echo @="%pcname%">>ComputerName.reg 
echo [HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlComputerName]>>ComputerName.reg 
echo [HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlComputerNameComputerName]>>ComputerName.reg 
echo "ComputerName"="%pcname%">>ComputerName.reg 
echo [HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlComputerNameActiveComputerName]>>ComputerName.reg 
echo "ComputerName"="%pcname%">>c:TempInfo.reg>>ComputerName.reg 
echo [HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesEventlog]>>ComputerName.reg 
echo "ComputerName"="%pcname%">>ComputerName.reg 
echo [HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlComputerNameComputerName]>>ComputerName.reg 
echo "ComputerName"="%pcname%">>ComputerName.reg 
echo [HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesTcpipParameters]>>ComputerName.reg 
echo "NV Hostname"="%pcname%">>ComputerName.reg 
echo "Hostname"="%pcname%">>ComputerName.reg 
echo [HKEY_USERS.DEFAULTSoftwareMicrosoftWindowsShellNoRoam]>>ComputerName.reg 
echo @="%pcname%">>ComputerName.reg 
regedit /s ComputerName.reg 
del /q ComputerName.reg 
echo     修改计算机器名称完成... 
del %0 

@echo off
set /p pcnanme=请输入计算机的名字:
reg add HKEY_LOCAL_MACHINESYSTEMControlSet001ControlComputerNameComputerName /v ComputerName /t REG_SZ /d %pcnanme% /f
eixt

 

需要重启电脑才能生效

 

二、不需要重启

@echo off
set /p name=输入新的计算机名称
wmic computersystem where "PrimaryOwnerName='%username%'" call rename %NAME%&exit
利用wmic改名不用重启

 

 

通过修改注册表修改主机名和工作组

@echo off
echo AppLife.Net
set /p name=请输您的计算机名:
reg add "HKEY_LOCAL_MACHINESystemCurrentControlSetControlComputerNameActiveComputerName" /v ComputerName /t reg_sz /d %name% /f >nul 2>nul
reg add "HKEY_LOCAL_MACHINESystemCurrentControlSetServicesTcpipParameters" /v "NV Hostname" /t reg_sz /d %name% /f >nul 2>nul
reg add "HKEY_LOCAL_MACHINESystemCurrentControlSetServicesTcpipParameters" /v Hostname /t reg_sz /d %name% /f >nul 2>nul
echo.
echo 修改计算机名完毕
echo.
echo AppLife.Net
set /p work1=请输入您的工作组名:
wmic computersystem where Name="%COMPUTERNAME%" call JoinDomainOrWorkgroup Name="%work1%"
echo 修改工作组完毕
pause>nul
echo.

 

不需要重启

本文由操作系统发布,转载请注明来源:window批处理修改计算机名,自动修改计算机名