Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change windows hostname from command line [closed]

Is it possible to change the hostname in Windows 2003 from the command line with out-of-the-box tools?

like image 343
dmo Avatar asked Sep 10 '08 18:09

dmo


People also ask

How do I change my hostname in cmd?

How to change your PC Name via Command Prompt? 1) Press the Windows key + X to open the Quick Access menu. Then, click on Command Prompt (Admin). 2) In the Command Prompt, type WMIC computersystem command to change your computer name, assuming you know the current computer name.


2 Answers

The previously mentioned wmic command is the way to go, as it is installed by default in recent versions of Windows.

Here is my small improvement to generalize it, by retrieving the current name from the environment:

wmic computersystem where name="%COMPUTERNAME%"       call rename name="NEW-NAME" 

NOTE: The command must be given in one line, but I've broken it into two to make scrolling unnecessary. As @rbeede mentions you'll have to reboot to complete the update.

like image 98
Gringo Suave Avatar answered Oct 04 '22 19:10

Gringo Suave


cmd (command):

netdom renamecomputer %COMPUTERNAME% /Newname "NEW-NAME" 

powershell (windows 2008/2012):

netdom renamecomputer "$env:COMPUTERNAME" /Newname "NEW-NAME" 

after that, you need to reboot your computer.

like image 32
litao Avatar answered Oct 04 '22 18:10

litao