I have been asked this question many times on this blog – ‘How to rename a local user account from command line?’ Well, net user command supports most of the user account related operations that we can do from Control Panel-> User accounts in GUI. It supports password reset, locking or unlocking user accounts, adding users to groups etc. One thing the GUI supports and net user command does not support is renaming user accounts. Still, there is a way to do that from windows command line. We need to use WMIC Useraccount command for doing this.
Below is the command for renaming a local user account on a computer.
wmic useraccount where name='currentname' rename newname
Example: To rename the user account ‘xpuser’ as ‘win7user’ we can run the below command.
wmic useraccount where name='xpuser' rename win7user
Using this command we can rename administrator account also. The below command changes the user name from ‘administrator’ to ‘admin.’
wmic useraccount where name='administrator' rename admin
The above wmic commands work on XP, Server 2003, Vista, Windows 7 and Server 2008. On Vista and Windows 7, you need to run the commands from elevated command prompt.
it say that wmic is not recognized as internal or external command
Same I’m getting the same thing
Love this, thanks much… The gui would not perm change the uname, this worked like ‘magic’. PS: not real email, but sentiment is legit!
Thanks Steve for the comment. Appreciation like this keeps us going.
PS: no problem with the email id.
Can not figure out how to change name. Help. Thank you
I recently renamed my user account, but the command prompt still shows my old name under , what gives?
This is perfect! Thanks so much. Had never heard of this command before. Had to use it to change the guest account name in Windows 8.1 (non-pro) before activating the account for the first time. Only other way to change the guest account name is to activate it and change in the user accounts panel, but then certain elements of the account still refer to “Guest”. I then used “net users” to verify the change.
Win8 Elevated Command Prompt: StartKey+X or Right click Start button, click on “Command Prompt (Admin)”
Not working. It says “Prashant-Invalid alias verb”.
Make sure the syntax is correct.
I unfortunately either deleted the only administrator account I had in my Control Panel, or inadvertently changed it incorrectly. I tried every one of your suggestions, and none of them worked. I’m still hoping you can get an administrator for me for Users in the Control Panel, please. Thank You
Thank you for the wonderful post.
it really helped me out with my problem.
Thank u very much~
Did not work for me. It said successful, but it didn’t change anything. Thanks anyway!
I think you just have to run the command prompt as an administrator and try again.
After doing the step restart your system before the system can show the new user name
Hey thanks man. It work for me
ReturnValue = 0;
this command renames the domain user in the same time, if there is a domain user with the same username of a local user
I tried changing the user account name with both regular command prompt & then elevated. Both came back w/ success message but on restart, when command prompt opened, always showed old name. I am using windows 7 pro, sp1, 64 bit. When I did elevated command, prompt showed Windows\system 32 instead of account name. Don’t know if that was supposed to show.
That’s strange, can’t think of what could be wrong. Regarding elevated cmd, it always opens up in c:\windows\system32 folder, that’s not a problem.
What to do when user name have space in between the name?
Single quotation or double quotation doesn’t work.
I found the below command to be working
After rename, double clicking the user account in computer management(compmgmt.msc) had thrown below error for me.
‘The following error occurred while attempting to read the properties of the user.
An unknown directory object was requested’
I had to close ‘computer management’ window and reopen to see the accounts with new name.
Worked like a charm…. thx !
Hi. Can I use this in windows 10? I’m trying to change a username with an apostrophe. I will Like to change Félix Quinones to Felix Quinones. Thanks
After I used the command you provided, and then type “echo %username%” that still shows me the old username, how should I do?
I tried wmic useraccount where name=’test 1′ rename ‘test 2’ and received this
Hint: = [, ]
What is this? I am trying to change my daughter’s name on her laptop computer. Her sisters set it up for her school and now everyone sees her as ‘Hoochie Mama’ – not funny but funny for my teenage daughters. Please please please help me change this.
Thank you so much! Worked perfectly
I changed the administrator name in Win Server 2012r2 and now after rebooting Windows can’t start. How can I fix it? can I do it by Net user commands?
for win10 users , it is
wmic useraccount where name=’old name’ call rename name=’new name’
I’ve used solution provided on post and it worked on my Windows 10 Enterprise 2016 LTSB
Hi, thanks for leaving this reply – I tested too
“wmic useraccount where name=’old name’ call rename name=’new name’” will work when using W10 systems, and you need to run Cmd as Admin. No need to restart.
Tried this, but it is giving “invalid query” error message.
hey man, this worked successfully, big thanks!
I’m using a modified Windows 10 Enterprise 2016 ISO on my Aspire One 722 Netbook and wasn’t able to change user account name by settings app or control panel, and this cmd option solved my problem
God bless you!!!
Does not work with PowerShell nor Command Prompt.
why not using C:\Windows\System32\Netplwiz.exe to rename in GUI?
im gettin an error it says invalid query what would that mean?