Solved

Attempting to change the Computer Name via a Batch FIle

Posted on 2007-11-30
5
2,351 Views
Last Modified: 2011-10-03
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
0
Comment
Question by:Rstoehrer
5 Comments
 
LVL 30

Accepted Solution

by:
LauraEHunterMVP earned 500 total points
ID: 20383030
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
0
 
LVL 26

Expert Comment

by:farhankazi
ID: 20383146
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"
http://www.scriptinganswers.com/Archive/articles/RenameComputerandJoinDomain.htm

"Change computer name using WMIC (command line)"
http://nnihlen.com/blog/archive/2006/07/12/318.aspx

"Rename Computer"
http://techinfo.cnwl.ac.uk/Windows%20Scripts/default.asp?dest=Rename%20a%20remote%20computer.htm

Hope this helps!
Farhan


0
 
LVL 26

Expert Comment

by:farhankazi
ID: 20383217
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"
0
 
LVL 77

Expert Comment

by:Rob Williams
ID: 20383409
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
pause

Download NetDom as part of the XP resource tool kit:
http://www.microsoft.com/downloads/details.aspx?FamilyId=49AE8576-9BB9-4126-9761-BA8011FABF38&displaylang=en
Or download just the netdom utility (scroll 1/2 way down the page)
http://www.petri.co.il/download_free_reskit_tools.htm
0
 
LVL 11

Expert Comment

by:bsharath
ID: 20410029
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

Oldname:Newname

After renaming restart and then flushdns and register dns and restart

http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Q_22719092.html?cid=239#a19563668
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question