Sub topic 6
Shares and accounts with the net command
The net command is a family of subcommands for managing network connections, local accounts, groups, and services from Command Prompt. This chapter covers the two the A+ Core 2 exam asks about most: net use for shares and net user for accounts. It also touches net localgroup, which you need to make account changes useful.
This chapter assumes you can open an elevated Command Prompt and read /? help, as covered earlier. It also assumes you know what a UNC path is and how IP addresses and DNS names relate.
Mapping shares with net use
A share is a folder that another computer makes available over the network. You reach it with a UNC (Universal Naming Convention) path in the form \\server\share. net use assigns a drive letter to that path, so it behaves like a local drive.
net use Z: \\server\share /persistent:no
net use
net use Z: /deleteThe first command maps Z: for the current session only. The second, with no arguments, lists current mappings and their status. The third removes the mapping.
Common switches
| Switch | Effect |
|---|---|
| `/persistent:yes` | Reconnects the mapping at the next sign-in |
| `/persistent:no` | Discards the mapping at sign-out |
| `/user:name` | Connects with different credentials, such as `/user:DOMAIN\jsmith` |
| `*` in place of a password | Prompts for the password so it is not typed in plain text |
| `/delete` | Removes a mapping. `net use * /delete` removes all of them |
To connect with other credentials, use this form:
net use Y: \\server\finance /user:CONTOSO\jsmith * /persistent:yesThe * makes Windows ask for the password and hide what you type. Typing the password in the command is possible, but it lands in your screen history and can be seen by anyone watching.
How a connection attempt resolves
Errors worth recognizing
- System error 53: The network path was not found. The name does not resolve or the server is unreachable. Check with
pingandnslookup. - System error 67: The server answered, but the share name is wrong.
- System error 85: The drive letter is already in use. Pick another letter or delete the old mapping.
- System error 1219: Windows allows only one set of credentials per server per session. Disconnect existing connections to that server with
net use \\server /delete, then reconnect. - System error 1326: The user name or password is wrong.
- System error 5: The login worked, but the account lacks permission on the share.
Managing local accounts with net user
net user creates, changes, and removes user accounts. Changes need an elevated prompt. Without elevation you get "System error 5 has occurred. Access is denied."
net user
net user jsmith
net user jsmith *
net user tempuser Pa55w0rd! /add
net user tempuser /active:no
net user tempuser /deleteEach command does the following:
net userlists the local accounts.net user jsmithshows one account's details, including whether it is active, when the password was last set, when it expires, and which groups the account belongs to.net user jsmith *prompts for a new password for that account.net user tempuser Pa55w0rd! /addcreates an account with that password./active:nodisables the account without deleting it. Use/active:yesto re-enable it./deleteremoves the account permanently.
On a domain-joined machine, net user /domain queries the domain instead of the local account database. This works only when the machine can reach a domain controller.
Giving an account the right permissions
A new account created with net user /add is not an administrator. Rights come from group membership, and net localgroup manages that.
net localgroup
net localgroup Administrators
net localgroup Administrators tempuser /add
net localgroup Administrators tempuser /deleteThe first command lists local groups. The second lists the members of Administrators. The last two add and remove a member. Follow least privilege: put users in Users unless they need more.
Why the command line still matters
The graphical tools cover the same ground, such as Local Users and Groups in Computer Management, which later chapters describe. The command line is faster for scripts and remote sessions, and it works when the graphical tools are not available. It is also the answer the exam usually expects when a question names a command-line scenario.
Exam scenarios
| Scenario | Command |
|---|---|
| Connect a user to `\\fileserver\sales` as drive S: | `net use S: \\fileserver\sales` |
| Make a mapping survive a restart | Add `/persistent:yes` |
| Remove every mapped drive | `net use * /delete` |
| Check whether an account is locked or expired | `net user username` |
| Temporarily block a departed employee | `net user username /active:no` |
| Make a user a local administrator | `net localgroup Administrators username /add` |
Exercise
A technician runs net use S: \\fileserver\sales and gets "System error 67 has occurred." The user can ping the server by name. What is the most likely cause, and what is a good next step?
Show answer
Error 67 means the server was reached but the share name was not found, so the share name is probably misspelled or the share does not exist. Confirm the exact share name with the server's administrator, or run net view \\fileserver to list its shares, then retry the command with the correct name.
Exercise
You need to stop a former employee's local account from signing in but keep its profile data for review. Which command do you run, and why not /delete?
Show answer
Run net user username /active:no from an elevated prompt. This disables the account, but the profile and files stay in place. /delete removes the account permanently, and a re-created account would get a new SID and not match the old permissions.