How to Change a Computer Name & Verify Through DOS Prompt
For a Microsoft Windows computer on a network, the "Computer Name" is important because it helps users elsewhere on the network tell which computer is which to locate a particular machine, and may also determine which printers, file servers and other resources are available to the computer. Perhaps the easiest way to manually rename a single computer is to right-click the "My Computer" icon, select "Properties" from the context menu, click the "Computer Name" or "Network Identification" tab and then click the "Change" button.
But having a way to quickly change the computer name from the "Command prompt" or DOS shell can be useful when faced with the task of renaming multiple computers on a large network. This solution uses a Visual Basic script to satisfy that need.
Instructions
-
-
1
Click on the "Start" button with the Microsoft Windows logo in the corner of the screen, select "Run..." and then type "notepad" before clicking the "OK" button.
-
2
Paste the following Visual Basic code into the blank Notepad window that appears:
Name = InputBox("Enter the new computer name below and click OK to continue","Rename: Step 1")
Username = InputBox("Enter the admininstrator id below and click OK to continue","Rename: Step 2")
Password = InputBox("Enter the password below and click OK to continue","Rename: Step 3")Password = "test"
Username = "administrator"Set objWMIService = GetObject("Winmgmts:root\cimv2")
' Call always gets only one Win32_ComputerSystem object.
For Each objComputer in _
objWMIService.InstancesOf("Win32_ComputerSystem")Return = objComputer.rename(Name,Password,Username)
If Return <> 0 Then
WScript.Echo "Rename failed. Error = " & Err.Number
Else
WScript.Echo "Rename succeeded." & " Reboot for new name to go into effect"
End IfNext
-
-
3
Select "Save" in the "File" menu, type in the file name "c:\change.vbs" and click "Save" to store it in the root directory of "Local Disk (C:)" on "My Computer." Then, quit Notepad by selecting "Exit" in the "File" menu, or by clicking the red box in the corner of the window.
-
4
Click on the "Start" button with the Microsoft Windows logo in the corner of the screen, select "Run..." and type "c:\change.vbs" before clicking the "OK" button. You will be prompted to type in the new name you'd like to give the computer, your administrator ID and then the administrator password, clicking the "OK" button after each entry.
Or, to run the script from the "Command prompt" or DOS shell, click on the "Start" button with the Microsoft Windows logo in the corner of the screen, select "Run..." and type in "cmd" before clicking the "OK" button. They type "c:\change.vbs" and press the Enter key. Again, you will be prompted to type in the new name you'd like to give the computer, your administrator ID and then the administrator password, clicking the "OK" button after each entry.
-
5
Reboot the computer after the script displays a confirmation message to indicate that it completed successfully.
-
6
Verify that the name of the computer has been changed successfully by right-clicking the "My Computer" icon, selecting "Properties" from the context menu, clicking the "Computer Name" or "Network Identification" tab in the window that appears and then clicking the "Change" button.
Or, to verify the name from the "Command prompt" or DOS shell, click on the "Start" button with the Microsoft Windows logo in the corner of the screen, select "Run..." and type in "cmd" before clicking the "OK" button. At the DOS prompt type in "ipconfig /all" and press the Enter key. This will display the "host name," which should now be the new computer name you specified.
-
1
Tips & Warnings
It is also possible to rename a Windows computer from the "Command prompt" or DOS shell without using Visual Basic, with the help of Microsoft's Netdom.exe utility. However, netdom.exe must often be manually installed on each computer from a Windows Support Tools installation disc, a server or other source.
If Netdom.exe must first be installed on each machine, the process could be time-consuming, and it may also be overkill if other administrator tools included with Netdom.exe won't be needed for another purpose.