• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2393
  • Last Modified:

Attempting to change the Computer Name via a Batch FIle

I am attempting to build a script that will prepare a computer for deployment into our production environment.  However, one of the tasks that we would like to have automated is the generation of the computer name.  So, I was wondering if there is a way to safely change the computer name from within a batch file or VBScript.

Thank you for your time and i will be looking forward to hearing the responses.

Robert Stoehrer
1 Solution
netdom.exe can rename a computer from the command-line, assuming that it is run with administrative credentials on the machine in question: http://support.microsoft.com/kb/298593
Farhan KaziSystems EngineerCommented:
No doubt NetDom is an excellent tool for renaming computer names but If you are still interested in .vbs script then have a look at following scripts!

"Rename Computer and Join Domain"

"Change computer name using WMIC (command line)"

"Rename Computer"

Hope this helps!

Farhan KaziSystems EngineerCommented:
You can also change remote computer name with following one liner without using any external tool.
Try this:

Click Start -> Run -> Cmd.exe -> OK

WMIC /NODE:"OldComputerNameHere" ComputerSystem WHERE Name="OldComputerNameHere" Call Rename Name="NewComputerNameHere"
Rob WilliamsCommented:
To elaborate on NetDom:
Change the name of the computer remotely using the Netdom utility. I made a simple batch file as below, called it ChangeName.bat  and then simply enter  ChangeName.bat OldName NewName  to change the computer name, while logged onto the server. You will be prompted for a password to confirm. The pause statement is simply to keep the DOS window open to view any potential errors. Substitute a Domain Admin name for AccountName and the domain name for domain.
You can also just enter the netdom command and the appropriate parameters and switches.

:: Batch file:
Netdom RenameComputer %1  /NewName:%2  /UserD:domain\AccountName  /PasswordD:*  /Force /ReBoot

Download NetDom as part of the XP resource tool kit:
Or download just the netdom utility (scroll 1/2 way down the page)
See if this helps....

FOR /F "delims=: tokens=1-2" %a IN ('Type C:\Computers.txt') Do NetDom RenameComputer %a /newname:%b /userD:Domainname\administrator /passwordd:Password /reboot:10 /force

With this i can rename all computers in the computers.txt


After renaming restart and then flushdns and register dns and restart

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now