- Управление учетными записями Windows через командную строку CMD
- Описание команды NET USER
- Синтаксис команды NET USER
- Дополнительные параметы команды NET USER
- Примеры команды NET USER
- Видео — Работа с утилитой NET USER
- Enable or Disable user account from command line (CMD)
- Using wmic to disable user account
- Net user command : Manage user accounts from command line
Управление учетными записями Windows через командную строку CMD
Для просмотра и управления учетными записями через командную строку используется команда NET USER.
Если ввести команду net user без параметров, то она покажет список пользователей Windows. Для просмотра справки по команде необходимо указать параметр net user /?
Список основных команд для работы с учетными записями через командную строку:
Добавить пользователя | net user /add имя_пользователя пароль |
Включить учетную запись пользователя | net user /active:yes имя_пользователя |
Отключить учетную запись пользователя | net user /active:no имя_пользователя |
Удалить пользователя | net user /delete имя_пользователя |
Для добавления пользователя в группу в командной строке используется команда управления локальными группами net localgroup
Добавить пользователя в группу | net localgroup имя_группы имя_пользователя /add |
Удалить пользователя из группы | net localgroup имя_группы имя_пользователя /delete |
Например, необходимо создать учетную запись пользователя «Root» с правами администратора и паролем 12345.
Создаем учетную запись: net user /add root 12345
Добавляем созданного пользователя в группу администраторов: net localgroup Администраторы root
Описание команды NET USER
Команда NET USER предназначена для добавления, редактирования или просмотра учетных записей пользователей на компьютерах. При выполнении команды в командной строке без параметров отображается список учетных записей пользователей Windows, присутствующих на компьютере (эта команда также хорошо работает и в Windows 10). Информация об учетных записях пользователей хранится в базе данных Windows.
Синтаксис команды NET USER
net user [имя_пользователя [пароль | *] [параметры]] [/domain]
net user имя_пользователя <пароль | *>/add [параметры] [/domain]
net user имя_пользователя [/delete] [/domain], где
- имя_пользователя — Указывает имя учётной записи пользователя, которую можно добавить, удалить, отредактировать или просмотреть. Имя может иметь длину до 20 символов.
- пароль — Присваивает или изменяет пароль пользователя. Введите звездочку (*) для вывода приглашения на ввод пароля. При вводе с клавиатуры символы пароля не выводятся на экран.
- /domain — Выполняет операцию на контроллере основного для данного компьютера домена.
- параметры — Задает параметр командной строки для команды.
- net help команда — Отображение справки для указанной команды net.
- /delete — Удаление учетной записи пользователя.
Дополнительные параметы команды NET USER
- /active:
— Активирует или деактивирует учетную запись. Если учетная запись не активирована, пользователь не может получить доступ к серверу. По умолчанию учетная запись активирована. - /comment:»текст» — Позволяет добавить описание учетной записи пользователя (максимум 48 символов). Текст описания заключается в кавычки.
- /countrycode: nnn — Использует код страны, указанный для операционной системы, для реализации соответствующих языковых файлов при отображении пользовательской справки и сообщений об ошибках. Значение 0 соответствует коду страны, используемому по умолчанию.
- /expires: <дата | never>— Дата истечения срока действия учетной записи. Значение never соответствует неограниченному сроку действия. Дата указывается в формате мм/дд/гг или дд/мм/гг в зависимости от кода страны. Месяц может указываться цифрами, полностью или в сокращенном виде (тремя буквами). Год может указываться двумя ли четырьмя цифрами. Элементы даты разделяются слэшем (/) без пробелов.
- /fullname:» имя » — Полное имя пользователя (в отличии от имени учетной записи пользователя). Имя указывается в кавычках.
- /homedir: путь — Указывает путь к домашнему каталогу пользователя. Указанное место должно существовать.
- /passwordchg:
— Указывает, может ли пользователь изменять свой пароль (по умолчанию может). - /passwordreq:
— Указывает, должна ли учетная запись пользователя иметь пароль (по умолчанию должна). - /profilepath[:путь] — Указывает путь к профилю входа в систему пользователя.
- /scriptpath: путь — Путь к сценарию, используемому пользователем для входа в систему.
- /times: <время | all>— Время для входа в систему. Параметр время указывается в формате день[-день][,день[-день]],час [-час][,час [-час]], причем приращение равняется 1 часу. Название дней недели могут указываться полностью или в сокращенном виде. Часы могут указываться в 12- или 24-часовом представлении. Для 12-часового представления используются обозначения am, pm, a.m. или p.m. Значение all соответствует отсутствию ограничений на время входа в систему, а пустое значение обозначает полный запрет на вход в систему. Значения дней недели и времени разделяются запятой; несколько записей для значений дней недели и времени разделяются точкой с запятой.
- /usercomment:»текст» — Позволяет администратору добавить или изменить комментарий к учетной записи.
- /workstations: <имя_компьютера[. ] | *>— Позволяет указать до 8 компьютеров, с которых пользователь может войти в сеть. Если для параметра/workstations не указан список компьютеров или указано значение *, пользователь может войти в сеть с любого компьютера.
Примеры команды NET USER
- Для вывода списка всех пользователей данного компьютера служит команда: net user;
- Для вывода информации о пользователе «petr» служит следующая команда: net user petr;
- Для добавления учетной записи пользователя Petr с полным именем пользователя и правом на подключение с 8 до 17 часов с понедельника по пятницу используется следующая команда: net user petr /add /times:Пн-Пт,08:00-17:00/fullname:»Petr».
- Для удаления учетной записи необходимо ввести команду: net user petr /delete;
- Для отключения учетной записи необходимо ввести команду: net user petr /active:no.
Видео — Работа с утилитой NET USER
Enable or Disable user account from command line (CMD)
To disable a user from logging into system, we can disable the account by opening computer management console and double clicking on the entry for the user and then by selecting the check button “Account is disabled”
We can do the same by just running a simple command from windows command line.
For example, to disable a user account named John we can run the below command.
To re-enable the account :
In Windows 7, you need to run the above commands from elevated administrator command prompt(See How to open elevated command prompt in Windows 7 ). You would get the below error when you run them from normal command prompt.
Using wmic to disable user account
Below wmic command works for disabling a user account
For re-enabling user account
If run from command prompt without elevated admin privileges it would result in the below error.
Successful account updation would be like below.
This was really helpful! thanks
I’m so very thanks cause my notebook was success enabled account
Hey; this guide was very helpful, but is it possible to lock a user account while using it? For example, I am using my administrator account and I don’t need it anymore. Can I lock it using command prompt, or do I need to use another user account? If I can do that, what happens? Will the account instantly close, or will I have to restart to see changes?
Thanks
Is there any way to enable atleast one user account if all user accounts are disabled including administrator.
Try using WinRE Command prompt as root user to type “net user /active:yes” where is the username of a user of your PC.
If you know the administrator password you can do this from any account.
this way I was able to overcome restrictions imposed on Windows 8.1 Home (or whatever the basic version is) No access to Users and groups in Admin tools, yet the above is working.
Ive made all the accounts disable !! Even the administrator … and I’m not able to get into the windows in order to change it … any help would be appreciated
Daniel,
Why would you do that?
I think you should just redeploy Windows on your system
Useless completely ! Why . CCE has tamper with UAC and locked me off of my administrative access rights in my Admin account and i have no access at all to change something . And this is only possible with MS under Linux no such thing . MS has invented access rights where only one administrative access can be locked out and newer again unlocked due no administrative access possible any more ! Format and installing it again is the only repair possible under such circumstances . Stupid MS credentials audit and administrative access results in self contained crippling system to the point of no use . One don’t need a virus MS it self is self crippled OS ! This one is shoot into the knee by them self and on my nerves . Its like being locked out of your car with the keys in it ! Very nice direct comparison ! Solve that . This is why i hate MS more and more – making huge troubles where troubles can be avoided ! What the hell they code .
If you have a second computer or someone that can help, download a Linux live CD (many flavors out there) to boot your PC. You may be able to setup a new Admin account without having to even log onto Windows.
http://www.howtogeek.com/howto/14369/change-or-reset-windows-password-from-a-ubuntu-live-cd/
how can i disable/enable the current user without know what’s his name
Is there ‘Current user’or any thing like that
please help me
Just type ‘net users’ into cmd, then look for the account with the name you don’t know… then type “net user ‘the account name’ /active:yes or no”
Net user command : Manage user accounts from command line
Using Net user command, administrators can manage user accounts from windows command prompt. Below are some examples on how to use this command.
Add a domain user account:
Add new user on local computer:
Advanced options to add new user account can be read in the below article.
Add new user from windows command line.
Disable/Lock a domain user account:
To enable/unlock a domain user account:
Prevent users from changing their account password:
To allow users to change their password:
To retrieve the settings of a user:
thaaaaaaaaanx man for the precious information
One Extra Feature that might be very useful.. is to set the Password to Never Expires:
I am using the /EXPIRES:NEVER switch on the end of the command, however the Never Expires checkbow is not ticked when i check the properties
Please notice that the /expires – switch prevents the the account from expiring, but not to the password.
That’s correct. Thanks Ray for clarifying it here for the benefit of others.
Use This Command To Set “Password Never Expire”
WMIC USERACCOUNT WHERE “Name=’username_here’” SET PasswordExpires=FALSE
Is there a way to change the net user username?
My question is how to create multiple users on a network through a command in command prompt using only single command line.
with a loop for.
FOR/L %variable IN (start, step, end) DO command [Settings]
for /L %U in (10,1,20) do net user user-%U Password /add /dom
(to create 10 users named user-10, user-11 to user-20)
check FOR /F [“options”] %%parameter IN (“Text string to process”) DO command
it’s works but not secure
Very good post on windows command line. Thanks for sharing.
Your command for “Add a domain user account” is incorrect, the proper one is:
Net user domainuser domainpassword /add /domain
Gives result:
“The request will be processed at a domain controller for domain softros.local.
The command completed successfully.”
hi how can i create multiple users from cmd
but just with one command??
i know for creating a new user i can use this:
net user username password /add
and to make him an administrator i can use this:
net user username password administrator /add
correct me if i’m wrong and help me please.
Your query, [hi how can i create multiple users from cmd
but just with one command??] – did you ever get an answer to that question ?
Please let me know.
i am currently locked out of my local administrator account on my windows server 2008 r2
i am able to change user accounts and passwords how ever it still telling me that my username or password is incorrect.
i have created a new user account and password but even the new user account and password doesnt work.
Is there a way to put a number of hours logon to the guest account?
interesting stuff here .. Thanks …
hi every body…
please help me how to add users with environment variable(starting program)?
How can I know who changed password for a user on windows server 2008 R2 from CMD and OS?
How can I check from our Internal domain and not our normal /domain?
Thanks so much! However is there a line to reset a password?
Hi I have forgotten my password to get onto the two accounts set up. When I go into net user neither accounts are showing. I get a message saying
The command completed with one or more errors
Can anyone help
hello guys in my college when i type the command “net users” it shows two accounts one is “guest” and another is “administrator” but in the login screen there are two accounts one is “guest” and another is “ADMIN” .why this ‘ADMIN’ account is not showing in the cmd.
Is there a command line command to add a group or user name under the security tab option Group or user names: for a domain user?
How to check a user which was created in a different trusted domain. Not to the machine joined.
How can we check for an account creation or disablement date in cmd
How can we run a command to replace the email address in AD from powershell
I need your assistance with batch command tomake this change in my secpol.msc!
i need to set the “password policy” > Password must meet complexity….. to be DISABLED or ENABLED
Just be aware that unlocking/enabling a user account also sets it so that the password must be changed on next logon.
I limit login time with “net user time” command of our son account on W10, but when time expire … he is logout from his User account and login under Admin account WITHOUT been asked for Admin´s password!
Any idea why? Thank you.
Please help me can you find the password for profile, when you are on it.
The article seems to think these are the same things.
They are NOT:
Enabled/disable an account.
Lock/unlock an account.
why does the last logon line read “never”? i have this with my current user which i am trying to time restrict. it wont restrict because it claims to have never logged in.
How can I pull the information of a user who is the different domain in Active Directory like IN or BR or AR?
Hello,
Great read! I am hoping u can help me. I am trying to set time limits for a user. However it completed successfully and still allows user to logon when he is not supposed too! Any advice.
what command i can use get net user status in a single query ?i looking for the format
example
account status
admin enabled