Change computer name from command line

by admin on October 23, 2011

We can rename a windows computer from command line using WMIC computersystem command. Please see the command below

WMIC computersystem where caption='currentname' rename newname

Example: If the current computer name is XP-PC, to change it to Windows7-PC, we can run the below command.

wmic computersystem where caption='xp-pc' rename windows7-pc

After running the command, you need to reboot the computer to make the changes effective.

This command works on XP, Vista, Windows 7 and also on Server 2003 and Server 2008 editions. This command can also be used from a batch file to rename computer. On Vista and Windows 7, this rename command can be run only from elevated administrator command prompt. If you run it from a normal command prompt, you would get the below error.

C:\>wmic computersystem where caption='xp-pc' call rename windows7-pc
Executing (\\XP-PC\ROOT\CIMV2:Win32_ComputerSystem.Name="XP-PC")->rename()
Method execution successful.
Out Parameters:
instance of __PARAMETERS
{
        ReturnValue = 5;
};
C:\>

IF you are trying to rename a computer joined to a domain, then the computer should be online when you run the command. Otherwise you would get error 1355 as below.

C:\>wmic computersystem where caption='xp-pc' rename windows7-pc
Executing (\\XP-PC\ROOT\CIMV2:Win32_ComputerSystem.Name="XP-PC")->rename()
Method execution successful.
Out Parameters:
instance of __PARAMETERS
{
        ReturnValue = 1355;
};

Error 1355 means that the specified domain can’t be contacted. On successful execution of the command, the return value would be ’0′.

{ 0 comments… add one now }

Leave a Comment

HTML tags are not allowed.

Previous post:

Next post: