How to change a Windows username using the command prompt?

You can use wmic for this. The command is:

wmic useraccount where name='currentname' rename newname

Example, if your username is "user" and you want to rename to "person" the following command would be used.

wmic useraccount where name='user' rename person

Please note, you need administrative privileges to use this command, so make sure you start your command prompt using run as administrator.

EDIT: suddenly you mention in the comments that you do NOT want to change the Username, but the Full Name instead.

The command for that is here:

wmic useraccount where fullname='currentname' rename newname

You can substitute fullname or name for any of the following:

AccountType  Description  Disabled  Domain    FullName     InstallDate  LocalAccount  Lockout  Name   PasswordChangeable  PasswordExpires  PasswordRequired  SID  SIDType  Status

You can use the following command to see a list of all users with all their settings:

wmic useraccount list

The following will do what you want:

net user JDoe /fullname:"John Doe"

The wmic solution didn't work for me, and apparently WMIC is now deprecated as of Windows 10 21H1. The following worked for me in an elevated PowerShell, however:

(Get-WmiObject Win32_UserAccount -Filter "name='oldname'").Rename("newname")

This is also deprecated, apparently, but at least it works. I couldn't figure out the newer CIM methods without getting some sort of No mapping between account names and security IDs was done. error.


In my case wmic doesn't take effect, after lots of search, finally I find create another account and delete current account works.

Go to Control Panel > User Accounts, create a new account with new user name, and set it to Administrator. Then log out, and log in with new account, then delete the old account, it works.