cmd Adding and Managing Users


Adding and managing users in Windows through the Command Prompt (cmd) involves using the net user command and the net localgroup command. These commands allow you to create, modify, and delete user accounts, as well as manage their group memberships. Below, I’ll explain how to perform these operations along with examples and expected outputs.

1. Viewing Existing Users

To view a list of existing user accounts on the system, you can use the following command:

Command:

net user

Example:

C:\> net user

Output:

User accounts for \\YOUR-COMPUTER ------------------------------------------------------------------------------- Administrator Guest YourUsername User1 The command completed successfully.

Output Explanation: This command displays a list of all user accounts on the local machine.

2. Adding a New User

To add a new user account, you can use the net user command with the following syntax:

Basic Syntax:

net user [username] [password] /add

Example:

To add a new user named NewUser with a password Password123, enter:

net user NewUser Password123 /add

Output:

C:\> net user NewUser Password123 /add The command completed successfully.

3. Modifying an Existing User

You can modify an existing user account by using the same net user command with various options. For example, you can change a password or add the user to a specific group.

Basic Syntax to Change Password:

net user [username] [newpassword]

Example:

To change the password of NewUser to NewPassword123, enter:

net user NewUser NewPassword123

Output:

C:\> net user NewUser NewPassword123 The command completed successfully.

4. Deleting a User

To delete an existing user account, use the following command:

Basic Syntax:

net user [username] /delete

Example:

To delete the user NewUser, enter:

net user NewUser /delete

Output:

C:\> net user NewUser /delete The command completed successfully.

5. Adding Users to Groups

You can manage user group memberships using the net localgroup command.

Basic Syntax to Add a User to a Group:

net localgroup [groupname] [username] /add

Example:

To add NewUser to the Administrators group, enter:

net localgroup Administrators NewUser /add

Output:

C:\> net localgroup Administrators NewUser /add The command completed successfully.

6. Removing a User from a Group

To remove a user from a group, use the following syntax:

Basic Syntax:

net localgroup [groupname] [username] /delete

Example:

To remove NewUser from the Administrators group, enter:

net localgroup Administrators NewUser /delete

Output:

C:\> net localgroup Administrators NewUser /delete The command completed successfully.

7. Viewing User Details

To view detailed information about a specific user, you can use:

Command:

net user [username]

Example:

To view details of YourUsername, enter:

net user YourUsername

Output:

C:\> net user YourUsername User name YourUsername Full Name Your Full Name Comment Your comment here User's comment <none> Country/Region info 000 (System Default) Account active Yes Account expires Never Password last set 10/01/2024 1:00 PM Password expires Never Password changeable 10/01/2024 1:00 PM Password required Yes User may change password Yes Last logon 10/29/2024 10:00 AM Logon hours allowed All Local Group Memberships *Users Global Group memberships *None The command completed successfully.

Output Explanation: This command provides detailed information about the specified user, including the account status, password settings, last logon time, and group memberships.

Summary

Adding and managing users in Windows via the Command Prompt can be efficiently accomplished using the net user and net localgroup commands. These commands allow you to view existing users, create new accounts, modify user settings, delete accounts, and manage group memberships. Understanding these commands is essential for system administrators and users who want to manage their Windows environment effectively.