To modify the computer name by using a batch program code described by the workgroup computer _dos/bat

Source: Internet
Author: User

Copy Code code as follows:

@echo off
Echo Chun Long packaging computer name, computer description, workgroup modify Batch Program
Echo
Pause
Cls
: set/p id= Please enter the local network segment number:
: set/p ip= Please enter the native IP address:
: netsh interface ip set address name= "Local Area Connection" Source=static addr=192.168.%id%.%ip% mask=255.255.255.0
set/p name= Please lose your host factory s/n number:
REG ADD "Hkey_local_machine\system\currentcontrolset\control\computername\activecomputername"/V computername/t reg _SZ/D%name%/F
REG ADD "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters"/V "NV Hostname"/reg_sz/d%name%/F
REG ADD "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters"/V hostname/t reg_sz/d%name%/F
SET work= Chun Long
WMIC ComputerSystem where name= "%name%" Call JoinDomainOrWorkgroup name= "%work%"
set/p describe= Please enter your computer description (company specified must be user name):
REG ADD "Hkey_local_machine\system\currentcontrolset\services\lanmanserver\parameters"/V srvcomment/t reg_sz/d% Describe%/F

NET config server/srvcomment: "%describe%"
Pause

Modify the computer name and workgroup with a batch without rebooting!

If you like to use Ghost mirror system, then each reload after the completion of the computer name is a string of long random characters, very inconvenient and not beautiful.
In general, you modify the computer name or workgroup in the system properties, always reboot, very troublesome. Even in the latest Vista operating system.
In fact, the computer name is stored in the registry, we can modify the registry directly, to achieve the purpose of modification.

Copy Code code as follows:

Hkey_local_machine\system\currentcontrolset\control\computername\activecomputername
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters

The changes to the workgroup can be accomplished by a WMIC command.

WMIC ComputerSystem where name= "%computername%" Call JoinDomainOrWorkgroup name= "%workgroup%"
Now we'll write it as a batch to implement the change of computer name and workgroup without rebooting:

Copy Code code as follows:

@echo off
Echo applife.net
set/p name= Please lose your computer name:
REG ADD "Hkey_local_machine\system\currentcontrolset\control\computername\activecomputername"/V computername/t reg _SZ/D%name%/F >nul 2>nul
REG ADD "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters"/V "NV Hostname"/reg_sz/d%name%/F & Gt;nul 2>nul
REG ADD "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters"/V hostname/t reg_sz/d%name%/F > Nul 2>nul
Echo.
Echo Modifies computer name complete
Echo.
Echo applife.net
set/p work1= Please enter your workgroup name:
WMIC ComputerSystem where name= "%computername%" Call JoinDomainOrWorkgroup name= "%work1%"
Echo Modify Workgroup complete
Pause>nul
Echo.

Save the above code as a bat file and run it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.