Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I rename a computer from the command line?

All I can find on the net is how to rename it in a domain, but I just want to rename the computer before joining a domain.

share|improve this question
up vote 1 down vote accepted

You can use the Win32_ComputerSystem WMI class and invoke the rename method. You can implement the WMI call in a vbscript, or powershell or however you choose to run the process.

share|improve this answer
I was trying to avoid WMI because it's horribly difficult to use from within .NET. It's easy from Powershell but Microsoft have made sure that we cannot be sure whether Powershell is available on all Windows machines. I hate vbscript and want it to die. – Andrew J. Brehm Jun 16 '10 at 13:55
I hear you and I can appreciate that, but I have found that WMI is pretty useful and if you power through a few lines you will find you reuse a lot of the same code and can develop faster in the future when you need another script. – BoxerBucks Jun 16 '10 at 14:16
Yepp. I am working on the WMI solution now. I hope it accepts an array of strings with the new name and two nothings as a paramter. – Andrew J. Brehm Jun 16 '10 at 14:39
As long as you are executing it in the context of a user that has rights to do the rename and you pass "NULL" to the username and password parameters, it will work. Good luck! – BoxerBucks Jun 16 '10 at 18:07

You can use NETDOM


See this article

share|improve this answer
I don't know why this was upvoted twice. It renames a computer IN a domain. I want to rename a computer BEFORE joining a domain. – Andrew J. Brehm Jun 17 '10 at 8:20
You don't have to be a member of a domain it just provides the additional functionality that you also can when you are a member - make sens? – CPU_BUSY Jun 17 '10 at 16:45

if your trying to rename a workstation and you want to guarantee the processes are available

wmic computersystem call rename "newname" to change a local name

wmic /node:oldname computersystem call rename "newname" for a remote name change

please note I can't test these right now but I'm sure they'll work.

share|improve this answer
I'll try this. I have a VM for tests. – Andrew J. Brehm Jun 17 '10 at 8:25
I think it's missing the second and third parameter for "rename". How do I add two NULLs? – Andrew J. Brehm Jun 17 '10 at 8:28
"","" should do it! – tony roth Jun 17 '10 at 14:56
I tried two empty strings which were obviously not the same as two NULLs. Anyway, I now did the renaming thing using WMI from .NET. – Andrew J. Brehm Jun 17 '10 at 20:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.