Содержание
- To add a new user account to the domain:
- Rename a user account
- Few more advanced uses of net user command.
- Errors:

Просто начните набирать «Командная строка» в поиске, а когда нужный результат будет найден, нажмите «Запуск от имени администратора» в правой части или, если такого не обнаружится (в ранних версиях Windows 10), нажмите по найденному результату правой кнопкой мыши и выберите нужный пункт контекстного меню.
Add new user account from command line (CMD)
Adding users from command line is much easier rather than going through UI. It saves lot of time for Windows admins to add users in bulk using CLI commands/script. Net user command is the one that Windows users can use to manage user accounts, read on to know how to add users from CMD. To add a new user account on local computer:
net user username password /ADD
Example: To add a new user account with the loginid John and with password fadf24as
net user John fadf24as /ADD
Hide password
If you do not want the password to be visible while adding new user account, you can use ‘*’ as shown below.
C:\>net user /add John * Type a password for the user: Retype the password to confirm: The command completed successfully. C:\>
To add a new user account to the domain:
net user username password /ADD /DOMAIN
Note that the command does not include the name of the domain, it automatically adds to the domain the computer belongs to. Example:
net user John fadf24as /ADD /DOMAIN
Rename a user account
Net use command does not have any switches to rename a user account. But we can do that using wmic commands. Please check this – Rename user accounts on Windows
Few more advanced uses of net user command.
To set user full name while creating the user account
net user username password /ADD /FULLNAME:"User_Fullname"
To allow user to change password:
net user username password /ADD /PASSWORDCHG:Yes
To restrict user not to change the password:
net user username userpasswd /ADD /PASSWORDCHG:NO
To set account expiry time we can use /EXPIRES switch. This can also be used to set that the account never expires. To specify if the user must have a password set we can use /PASSWORDREQ switch. For more information on all net user options, read this – Net user command: syntax and examples How to create a new administrator account? An administrator account can’t be created directly. We first need to create a user account and then add the user to the administrators group.
Errors:
- If you don’t have privileges to add new user account to the system, you would get an error like below.
C:\>net user John /add System error 5 has occurred. Access is denied. C:\>
C:\>net user testuser testpassword /ADD /DOMAIN The request will be processed at a domain controller for domain mydomain.com. System error 1355 has occurred. The specified domain either does not exist or could not be contacted.
Related Posts:
Add user to group from command line (CMD)
This command should be run when the computer is connected to the network. Otherwise you will get the below error.
H:\>net localgroup users domain\user /add System error 1789 has occurred. The trust relationship between this workstation and the primary domain failed.
To add a domain user to local administrator group:
net localgroup administrators domainname\username /add
To add a user to remote desktop users group:
net localgroup "Remote Desktop Users" UserLoginName /add
To add a user to debugger users group:
net localgroup "Debugger users" UserLoginName /add
To add a user to Power users group:
net localgroup "Power users" UserLoginName /add
This command works on all editions of Windows OS i.e Windows 2000, Windows XP, Windows Server 2003, Windows Vista and Windows 7. In Vista and Windows 7, even if you run the above command from administrator login you may still get access denied error like below.
C:\> net localgroup administrators techblogger /add System error 5 has occurred. Access is denied.
The solution for this is to run the command from elevated administrator account. See How to open elevated administrator command prompt
When you run the ‘net localgroup’ command from elevated command prompt:
C:\>net localgroup administrators techblogger /add The command completed successfully.
To list the users belonging to a particular group we can run the below command.
net localgroup group_name
For example to list all the users belonging to administrators group we need to run the below command.
net localgroup administrators
51 comments… add one
How to add a group to another group?
you can use the same command to add a group also. For example, to add a domain group ‘Domain\users’ to local administrators group, the command is:
net localgroup administrators domain\users /add
How can I add a user to a group remotely?
Using pstools, it is a good tools from Microsoft.
While this article is two years old – it still was the first hit when I searched and it got me where I needed to be. Another great tip is the syntax for doing a runas, because I needed to elevate a user’s privileges to admin from within his account:
runas /user:[email protected] "net localgroup Administrators DOMAIN\username /add"
Good stuff.
awesome! I’ve been wanting to know how to do this forever. thanks so much. for some reason, MS has made it impossible to authenticate protected commands via the GUI. seriously frustrating! this makes it all better.
Keith Poole
Is there a way to trough a password into the script for the admin account if it is known and generic
I tried the above stated process in the command prompt. Got to the point where it say’s “type in pass word” I start typing nothing happens. Curser does not move. Any suggestions. Windows 7 Ultimate system.
I think when you are entering a password in the command prompt the cursor does not move on purpose. You type in your password and press enter.
How to set password to never expire ?
You can run the below.
wmic useraccount where name='loginid' set passwordexpires=false.
Is there any way to add a computer account into the local admin group on another machine via command line? Thanks.
I don’t think that’s possible. However, you can add a domain account to the local admin group of a computer.
You might be able to use telnet to get a CMD shell. However, that would assume that you already have creds with the machine to build the telnet connection. If it were any easier than that it would be a massive security vulnerability.
Net localgroup \$ /ADD put the $ after the PC name and it works
Dude, thank you! On xp, the server service was not installed so couldn’t add via manage. User CtrlPnl gpf’s is broke (something about html app host error). In 3 seconds, you provided a way to fix that MS couldn’t with all their idiot wizards…
Hi Reue, Yes you can add any users to other computers remotely using the pstools.
Hello, I have a requirement something like this: I need to create a user account on a remote server which should be a part of the local administrator group. How should i set password for this user account ? Can any one help me please? Thanks in advance,
Prashanth
Read this: Add new user account from command line
Using psexec tool, you can run the above command on a remote machine.
I changed the admin account’s rights to user account and now i have only two accounts with only USER rights, nothing with admin. When ever i change any application, it says ” Right Admin Password” and there only comes NO and therefore i am unable to enter Admin Passowrd. Also i m unable to open cmd.exe as Admin. Please Advise.
Reinstall Windows. You literally broke it. I’m curious as to what edition of Windows you have, as most won’t actually let you remove the last member from the Administrators account, to avoid your very issue. For future reference, there’s really no good reason to ever make Administrator a mere User 😛
Deepak Sati
how can I add multiple domain users into local administrator group together with the single line command?
You can specify as many users as you want, in the same command mentioned above.
For example, to add three users :
net localgroup administrators domain\user1 domain\user2 domain\user3 /ADD
I don’t have access to the administrator account, but I do have access to my son’s
Standard Account. Please help.
Chris Olson
I am trying to add a service account to a local group but it fails. Is there syntax for that? I’ve tried many variations but no go. See below: net localgroup “Event Log Readers” “NT Authority\Network Service (S-1-5-20)” /add
Hi Chris,
I am trying the exact same thing ,to add network services to Adminstrators of Local Users and Groups .Did you find the solution.Please let me know. Thank You
Hi buddy I found the solution.Let me know if you still need it:-P
Hello Kiran,
Please add the solution here for the benefit of others. Thanks.
Thank you for this bunch of commands,
I have 2 questions:-How can I add all users in an Organisation unit into one group in Active directory ?
– & how can I add all users in Active Directory into a group?
1st make sure you have Remote Server Administration Tools (RSAT) add in features installed. Then click start – type cmd – hit Enter.
Type in commands below, replacing GROUP_NAME and OU_NAME with corresponding names (note that “‘ is double quote followed by apostrophe) then hit Enter and watch results:
for /f “tokens=*” %a in (‘dsquery ou -name “OU_NAME”‘) do for /f “tokens=*” %b in (‘dsquery group -name “GROUP_NAME”‘) do for /f “tokens=*” %c in (‘dsquery user %a -limit 0’) do dsmod group %b -addmbr %c for /f “tokens=*” %b in (‘dsquery group -name “GROUP_NAME”‘) do for /f “tokens=*” %c in (‘dsquery user -limit 0’) do dsmod group %b -addmbr %c
I do not have the administrator password eeven i do not want to reset because there are many apllications using this password. Is there are any way to create a new user with admin previleges into domain and works like a administrator clone. So i can log in with this new user and work like administrator. Is i boot and using “repair” option i need to have the admin password…
Is there are any way i can add a new user using another software? Thanks
Как создать пользователя в Windows 10 (разными способами).
AFAIK, That’s not possible. Otherwise anyone would be able to easily create an admin account and get complete access to the system. I think you should try to reset the password, you may need it at any point in future.
how can i open administrator account or super administrator account from user account when i cannot open cmd as administrator?
You can’t. That’s the point of Administrators. If you don’t have credentials as an Admin it’s probably because you were never meant to. Allowing you to do so would defeat the purpose. That said, there is a workaround involving running a cmd prompt basically as SYSTEM, but honestly, I’m not about to disseminate information on how to defeat security protocols. Sorry. It’s an ethics thing.
C:\Windows\System32>net localgroup administrators All /add
System error 5 has occurred. Access is denied.
how i can fix it
and i do not know password admin
(canot do this)
elow is the procedure to open elevated administrator command window on a Vista or Windows 7 machine. Click on Start button
Search for command program by typing cmd.exe in the search box.
Right click on the cmd.exe entry shown under the Programs in start menu
Select ‘Run as administrator’
Click on ‘continue’ if user account control asks for confirmation. The above steps will open a command prompt wvith elevated privileges.
There is an easier way if you want to use command prompt often. Search cmd.exe in from start and then right click and choose “Open file location”, once there in Windows Explorer you can right click on the actual file (cmd.exe) and “Send to” “Make Desktop Shortcut”. Next go to your desktop, right click on the shortcut, go to properties, advanced, check “Run as Administrator”. From here on out this shortcut will run as an Administrator. (For further use, pin the shortcut to taskbar or start menu.
Hello all! I am trying to get a user prompt for net localgroup Administrators /add \%u% to pop up while the batch file is running, I have tried adding Set /P after /add , is there something I’m missing to make it do this?
Worked perfectly for me, thank you. For the life of me the pc would not allow me to add a domain account to the local admin group, just wouldn’t work. Tried this from the command prompt and instant success. Thank you again!
Doesn’t work. “The trust relationship between this machine and the primary domain failed.”
Hi there, I accidentally turn my admin user into a standard user one. How do I change it back because when ever I try to download something my computer says that I don’t have permission. Thanks. ( I have Windows 7 )
Hi Guys I sort of have the same issue. I have a domain user DOMAIN\User on a laptop, but the user was never added to Local Admin. So this user cant make any changes. I have tried to log on as local admin, but still cant add the user to the group. It’s like the user does not exist. So how do I add a non local user, to local admin? Thanks Windows 7 Professional 64
Как создать или удалить учетную запись от имени администратора через командную строку в Windows 7 8
please help me how to add users to a specific client pc?
While this article is six years old – it still was the first hit when I searched and it got me where I needed to be.
Hi,
what if I want to add a user to multiple groups? Thanks in advance
Is there a command prompt for how to clone an existing user security groups to another new user?
I ran this net localgroup administrators domainname\username /add
and worked for me, using windows 10 pro. Thank you so much! Was the only way to put my user inside administrators group.
Very Informative webpage, thanks for the information, am going to check tomorrow when in work to see if can help with enabling a locked down user start a program that needs administrative abilities, but once program started the administer priviledges need removing, I thin your info will solve my problem so thanks if it does, if it doesnt I’ll leave another comment with HELP!!
Bob_Smith
If you get the Trust Relationship error make sure the “netlogon” service is running on the workstation. You’ll see this a lot in when trying to update group policies as well.
Hi Really well laid out article with no “Look what I know” fluff. Thank you and we will add the advise as go to resource!
how can I add domain group to local administrator group on server 2019 ?
net localgroup testgroup domain\domaingroup /add
does not work: The global user or group account does not exist: Thanks
Как запустить командную строку от имени Администратора
Командная строка от имени администратора в Windows 10
Существует множество способов запуска командной строки от имени Администратора, многие из которых работают независимо от того, какая версия ОС у вас установлена. Но, пожалуй, самый удобный и быстрый способ запустить cmd.exe с правами администратора в Windows 10 — использовать поиск в панели задач:

Просто начните набирать «Командная строка» в поиске, а когда нужный результат будет найден, нажмите «Запуск от имени администратора» в правой части или, если такого не обнаружится (в ранних версиях Windows 10), нажмите по найденному результату правой кнопкой мыши и выберите нужный пункт контекстного меню.
Также, если в Windows 10 вы зайдете в Параметры — Персонализация — Панель задач и отключите пункт «Заменить командную строку оболочкой PowerShell», то пункт для запуска командной строки от имени администратора появится в контекстном меню кнопки пуск (открыть можно правым кликом по этой кнопки или сочетанием клавиш Win+X).
Запуск командной строки от администратора в Windows 8.1 и 8
Для того, чтобы запустить командную строку с правами администратора в Windows 8.1 есть два основных способа (еще один, универсальный способ, подходящий для всех последних версий ОС я опишу ниже).
Первый способ заключается в нажатии клавиш Win (клавиша с эмблемой Windows) + X на клавиатуре с последующим выбором из появившегося меню пункта «Командная строка (администратор)». Это же меню можно вызывать правым кликом мыши по кнопке «Пуск».

Второй способ запуска:

- Перейдите на начальный экран Windows 8.1 или 8 (тот, который с плитками).
- Начните на клавиатуре набирать «Командная строка». В результате слева откроется поиск.
- Когда в списке результатов поиска вы увидите командную строку, кликните по ней правой кнопкой мыши и выберите пункт контекстного меню «Запуск от имени администратора».
Вот, пожалуй, и все по этой версии ОС, как видите — все очень просто.
В Windows 7
Чтобы запустить командную строку от имени администратора в Windows 7, проделайте следующие шаги:

- Откройте меню Пуск, пройдите в Все программы — Стандартные.
- Кликните правой кнопкой мыши по «Командная строка», выберите пункт «Запуск от имени Администратора».
Вместо того, чтобы искать во всех программах, вы можете ввести «Командная строка» в поле поиска внизу меню Пуск Windows 7, а потом проделать второй шаг из описанных выше.
Еще один способ, для всех последних версий ОС
Командная строка — это обычная программа Windows (файл cmd.exe) и запустить ее можно как любую другую программу.
Находится она в папках Windows/System32 и Windows/SysWOW64 (для 32-разрядных версий Windows используйте первый вариант), для 64-разрядных — второй.

Так же, как и в описанных ранее способах, вы можете просто кликнуть по файлу cmd.exe правой кнопкой мыши и выбрать нужный пункт меню, чтобы запустить его от имени администратора.
Есть и еще одна возможность — вы можете создать ярлык для файла cmd.exe там, где вам нужно, например, на рабочем столе (например, перетащив правой кнопкой мыши на рабочий стол) и сделать так, чтобы он всегда запускался с администраторскими правами:

- Кликните правой кнопкой по ярлыку, выберите пункт «Свойства».
- В открывшемся окне нажмите кнопку «Дополнительно».
- Отметьте в свойствах ярлыка «Запуск от имени администратора».
- Нажмите Ок, затем снова Ок.
Готово, теперь при запуске командной строки созданным ярлыком, она всегда будет запускаться от администратора.
А вдруг и это будет интересно:
- Лучшие бесплатные программы для Windows
- Как разогнать монитор в Windows
- Как добавить сайт на рабочий стол Android
- Razer Axon — анимированные обои на рабочий стол Windows
- Не работает поиск Windows 11 — как исправить?
- Как изменить значок для типа файла в Windows 11 и 10
- Windows 11
- Windows 10
- Android
- Загрузочная флешка
- Лечение вирусов
- Восстановление данных
- Установка с флешки
- Настройка роутера
- Всё про Windows
- В контакте
- Одноклассники
-
Талгат 19 Марта 2017 в 12:30
- Dmitry 20 Марта 2017 в 09:06
- Dmitry 5 Ноября 2017 в 09:39
Посмотрите вот здесь: https://remontka.pro/reset-windows-password-easy-way/ (для 7 и 8, там же есть ссылка на инструкцию про Windows 10, вначале как раз описывается запуск командной строки, когда нельзя зайти в систему). Ответить
а у меня почему то не получилось никак ее форматнуть..
Вот что у меня получилось
C:\Windows\system32>diskPart DISKPART> list disk Диск ### Состояние Размер Свободно Дин GPT -------- ------------- ------- ------- --- --- Диск 0 В сети 372 Gбайт 0 байт Диск 1 В сети 972 Mбайт 0 байт Диск 2 В сети 29 Gбайт 0 байт Диск 3 Нет носителя 0 байт 0 байт Диск 4 Нет носителя 0 байт 0 байт Диск 5 Нет носителя 0 байт 0 байт DISKPART> select disk 2 Выбран диск 2. DISKPART> clean DiskPart: очистка диска выполнена успешно. DISKPART> create partition primary Не найдены доступные свободные области. Возможно, на диске недостаточно места для создания раздела с заданным размером и смещением. Укажите другие значения размера и смещения или не указывайте их, чтобы создать раздел максимально допустимого размера. Возможно, разметка диска выполнена с использованием формата MBR и диск содержит либо 4 основных раздела (создание дополнительных разделов невозможно), либо 3 основных и 1 дополнительный раздел (допускается создание только логических дисков).
- Dmitry 29 Июня 2019 в 10:41
- Dmitry 19 Марта 2020 в 11:29
Вы имеете в виду вот так происходит? — https://remontka.pro/command-prompt-disabled-by-administrator/ если да, то в статье решения указаны возможные, при условии, что у вас на компьютере есть права администратора в принципе. Ответить
- Dmitry 7 Января 2021 в 09:49
- Andrey 7 Января 2021 в 22:34
Похожие статьи
-
Добавить пользователя в windows
Рассмотрим альтернативный способ предоставления возможности доступа к удаленному рабочему столу. Открываем меню Пуск и выбираем Панель управления. Зачем…
-
Целью этого способа является расширение текущего доступного пространства без изменения состояния раздела на жестком диске. 3 способа: Как увеличить место…
-
Итак начнем, существует несколько способов редактирования. По-сути главная задача — это дать текстовому редактору необходимые для редактирования файла…