Rename Windows computer name from the command line

Andy

Well-known member
Creative Team
User ID
1
Joined
7 Jan 2019
Messages
1,768
Reaction score
145
Points
63
For any reason, if you need to rename Windows computer name from the command line, here's the command:
Code:
WMIC computersystem where name="%computername%" call rename name="NewComputerName"

Example output:
Code:
C:\WINDOWS\system32>WMIC computersystem where name="OldComputerName" call rename name="NewComputerName"
Executing (\\OldComputerName\ROOT\CIMV2:Win32_ComputerSystem.Name="OldComputerName")->rename() Method execution successful. Out Parameters: instance of __PARAMETERS {    ReturnValue = 0; };
For the change to take effect, restart the computer using the command:
Code:
C:\WINDOWS\system32>shutdown /r /t 0
I tested running the commands above from ScreenConnect v21.4.2455.7731, and it worked as expected.
 
🟨 Update – July 2025:

As of Windows 11 (especially Home editions), WMIC is no longer included by default. Microsoft has deprecated it since Windows 10 21H1 and fully removed it from newer builds.

If you get:
Code:
'WMIC' is not recognized as an internal or external command...
This means the wmic.exe utility is no longer present on your system.

✅ Use PowerShell instead:
To rename the computer, open PowerShell as Administrator and run:
Code:
Rename-Computer -NewName "NewComputerName" -Force -Restart
This command will rename the computer and restart it immediately.

If you want to skip the restart for now, simply remove -Restart.
 
 Short URL:
Back
Top