Velvet Star Monitor

Standout celebrity highlights with iconic style.

news

How to change a Windows username using the command prompt?

Writer Sebastian Wright

I'm a Windows 7 user i used to change the username from the control panel. But I would like to know how to change it using the CLI not the GUI I have searched alot but didn't find the answer or it was unclear. A simple explanation to the code would be great

5 Answers

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
10

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.

If you're using powershell, you can also use the cmdlet Rename-LocalUser like this:

Rename-LocalUser -Name "Kylem" -NewName "kylemit"

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy