There are many ways that Windows modifies the hostname by scripting, and the script that modifies the registry is described below.
How to use:
1 Open cmd, if the foot name is Modifyhostname.bat
2 Execute the script and add the script parameters, where the first parameter is the new host name, the second parameter is the workgroup, the following script comments out the workgroup
Modifyhostname.bat Newhostname Newworkgrop
@echo offSetName=%1%Setwork1=%2%reg Add"Hkey_local_machine\system\currentcontrolset\control\computername\activecomputername"/V computername/t reg_sz/d% Name%/F >nul 2>Nulreg Add"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters"/V "NV Hostname"/t reg_sz/d%name%/F >nul 2>Nulreg Add"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters"/V hostname/t reg_sz/d%name%/F >nul 2 >nulEchoModify Computer name completeREMWMIC ComputerSystem where name= "%computername%" Call JoinDomainOrWorkgroup name= "%work1% "REMecho Modify Workgroup completeExit0
Windows Script modifies host name-does not restart