58

How would I go about making an Administrator account (read not limited) from the command line in Windows? I have seen commands to the effect of:

net user USERNAME PASSWORD /add

However it is unclear if an account created in this way would be an admin account or a limited account.

Zombo
  • 1

1 Answers1

93

You are on the right track - It takes two CMD line options to do this

First -

net user /add [username] [password]

This creates the user account.

net localgroup administrators [username] /add

This adds the user to the Local Administrators Group

You have to execute both commands with elevated permissions (an administrative CMD prompt)

EBGreen
  • 9,395
Chris E. Avis
  • 1,857
  • 12
  • 5
  • 11
    If your windows is not in English, you will have to translate "administrators" to your local language. You can type "net localgroup" to check the list of groups and see how it is called on your computer. – personne3000 Jun 22 '14 at 09:53
  • 2
    And what if you want to set "Password never expires" flag for the currently created user? How could you do that? – Saeed Neamati Aug 12 '14 at 07:34
  • 3
    Switches for net user are here: http://support.microsoft.com/kb/251394 – user36350 Dec 26 '14 at 17:35
  • @personne3000 for example: net localgroup | find /i "admin" (for latin alphabet) – Matthieu Oct 23 '19 at 15:55
  • @Matthieu ok you use "find" and how you use it to set... complete the code... –  Apr 07 '20 at 20:48
  • @FranciscoNúñez I was answering @personne3000's concern about localization of the "administrator" group name with a quick'n'dirty way for locales with latin alphabet (english, french, spanish, ...) where the english "administrator" is translated into "administrateur", "administrador", ... which all contain "admin". The good way would be to use group SID but cmd is far too limited for that; I'd guess you should store the find result in a variable and use it. – Matthieu Apr 08 '20 at 13:36
  • @SaeedNeamati to disable password expiry, it looks like you need to use wmic: wmic useraccount where "Name='MyUser' and LocalAccount=true" set PasswordExpires=false – mwfearnley Jan 10 '24 at 17:46