Modify the code described by the working group computer by using the batch processing program

Source: Internet
Author: User

Copy codeThe Code is as follows: @ echo off
Echo Junlong packaging computer name, computer description, workgroup modification batch processing program
Echo
Pause
Cls
: Set/p id = enter the local CIDR block number:
: Set/p ip = enter the local ip Address:
: Netsh interface ip set address name = "" source = static addr = 192.168.% id %. % ip % mask = 255.255.255.0
Set/p name = enter 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"/t 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 = Junlong
Wmic computersystem where Name = "% NAME %" call JoinDomainOrWorkgroup Name = "% work %"
Set/p describe = enter your computer description (the company requires the 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

Use batch processing to modify the computer name and Working Group. Do not restart!

If you like a system with a Ghost image, the computer name after each reinstallation is a long string of random characters, which is inconvenient and not beautiful.
Generally, it is very troublesome to modify the computer name or working group in the system attribute. This is even true in the latest Vista operating system.
In fact, the computer name is saved in the registry. We can modify the Registry directly.

Copy codeThe Code is as follows: HKEY_LOCAL_MACHINE \ System \ CurrentControlSet \ Control \ ComputerName \ ActiveComputerName
HKEY_LOCAL_MACHINE \ System \ CurrentControlSet \ Services \ Tcpip \ Parameters

You can use a wmic command to modify the workgroup.

Wmic computersystem where Name = "% COMPUTERNAME %" call JoinDomainOrWorkgroup Name = "% WORKGROUP %"
Now we write it as a batch process to implement the change of the computer name and working group without restarting:

Copy codeThe Code is as follows: @ echo off
Echo AppLife. Net
Set/p name = enter 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"/t reg_sz/d % name %/f> 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: computer name modified
Echo.
Echo AppLife. Net
Set/p work1 = enter your workgroup name:
Wmic computersystem where Name = "% COMPUTERNAME %" call JoinDomainOrWorkgroup Name = "% work1 %"
Echo modified workgroup
Pause> nul
Echo.

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

Related Article

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.