16.19. Renaming a Computer

Problem

You want to rename a computer.

Solution

Using a graphical user interface

  1. Log on to the computer either directly or with a remote console application, such as Terminal Services.

  2. Open the Control Panel and double-click on the System Applet.

  3. Select the Computer Name tab and click the Change button.

  4. Under Computer Name, type the new name of the computer and click OK until you've closed all of the System applet screens.

  5. Reboot the machine.

Using a command-line interface

The following command renames a computer and the corresponding Active Directory computer account:

> netdom renamecomputer <ComputerName> /NewName <NewComputerName> /UserD 
<DomainUserUPN> /PasswordD * /UserO <ComputerAdminUser> /PasswordO * /Reboot

The renamecomputer option is only available in Windows XP and Windows Server 2003 (not Windows 2000).

Using VBScript

' This code renames a computer in AD and on the host itself.
' The Rename( ) method was introducted in Windows XP so this code works
' only against Windows XP and Windows Server 2003.
' ------ SCRIPT CONFIGURATION ------
strComputer     = "<ComputerName>"       e.g., joe-xp
strNewComputer  = "<NewComputerName>"    e.g., joe-pc
strDomainUser   = "<DomainUserUPN>"      e.g., administrator@rallencorp.com
strDomainPasswd = "<DomainUserPasswd>"
strLocalUser    = "<ComputerAdminUser>"  e.g., joe-xp\administrator
strLocalPasswd  = "<ComputerAdminPasswd>" ' ------ END CONFIGURATION --------- '########################### ' Connect to Computer '########################### ...

Get Windows Server Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.