net user

Overview

The "net user" command is a Command Prompt (Shell) command used to manage user accounts on a Windows operating system. It can be used to create, modify, or delete user accounts, as well as to change passwords and manage group memberships.

Syntax

1net user [username [password | *] [options]] [/DOMAIN]
2net user username {password | *} /ADD [options] [/DOMAIN]
3net user username [/DELETE] [/DOMAIN]
4net user username [/TIMES:{times | ALL}]
5net user username [/ACTIVE: {YES | NO}]

Add a user

To add a new user account:

1net user USERNAME PASSWORD /add

Delete a user

To delete a user account:

1net user USERNAME /delete

Add user to group

To add a user to a specific group:

Local

1net localgroup GROUPNAME USERNAME /add

Domain

1net localgroup GROUPNAME DOMAIN\USERNAME /add

Remove user from group

To remove a user from a specific group:

Domain

1net localgroup GROUPNAME DOMAIN\USERNAME /delete

Local

1net localgroup GROUPNAME USERNAME /delete

Reset password

To reset a password:

Domain

1net user USERNAME PASSWORD /domain /active:Yes

Local

1net user USERNAME PASSWORD

Set password to be changed upon sign-in

To set a password for a user that must be changed upon sign-in:

Domain

1net user USERNAME PASSWORD /domain /logonpasswordchg:yes

Local

1net user USERNAME PASSWORD /logonpasswordchg:yes

Unlock account

To unlock an account:

Domain

1net user USERNAME /domain /active:yes

Local

1net user USERNAME /active:yes

Lock an account

To lock an account:

Domain

1net user USERNAME /domain /active:no

Local

1net user USERNAME /active:no

Check if account is active

To check if an account is active:

The find command is case-sensitive:

1net user USERNAME | find "Account active"

Set logon times

To set the logon times for a user:

1net user USERNAME /times:{times | ALL}
  • times: Specifies the times that users are allowed to use the computer. The time is specified as day[-day][,day[-day]],time[-time][,time[-time]], limited to 1-hour increments.

Options

  • username: Name of the user account to add, delete, modify, or view.
  • password: Assigns or changes a password for the user account.
  • *: Produces a prompt for the password. The password is not displayed when you type it at a password prompt.
  • /DOMAIN: Performs the operation on the primary domain controller of the current domain.
  • /ADD: Adds a user account to the user accounts database.
  • /DELETE: Removes a user account from the user accounts database.
  • /TIMES:{times | ALL}: Specifies the logon hours.
  • /ACTIVE:{YES | NO}: Activates or deactivates the user account.

This comprehensive guide provides detailed examples for various operations using the net user command. By understanding these commands, you can effectively manage user accounts on a Windows operating system.