- Creates a user account on the local computer.
- Creates the user account’s password.
- Adds the user to the local administrator group.
net user USERNAME PASSWORD /add && net localgroup administrators USERNAME /add
This line of code is actually two different commands in one. The double ‘and’ (&&) joins both commands as if it is one. The Windows command line processes each command in order. As you can see, these commands are very straightforward. It uses the built-in NET USER and NET LOCALGROUP functions from the Windows command line. You can use this in your batch file scripts to perform some administrative tasks regarding local user accounts.
2012-05-21 UPDATE: If planning on using these commands in an MDT Task Sequence, you must separate each command into their own task. For example, task #1 would be the command to create the user account and task #2 is the command to add that user account to the local security group. Failure to separate the CMD commands will cause the task to fail when the sequence is reached. [Shoutout to Brian for this tip!]