Sub topic 5
Shares and accounts with the net command
This chapter assumes you can open an elevated Command Prompt, read /? help, and know what a network share and a local user account are. The net command covers both jobs. It connects to shared folders and manages local accounts.
Mapping shares with net use
A network share is a folder that another computer makes available over the network. Its path uses the UNC format (Universal Naming Convention): \\server\share. The net use command assigns a drive letter to that path.
net use Z: \\server\share /persistent:no
net use
net use Z: /delete- The first line maps
Z:to the share for this session only. With/persistent:no, the mapping disappears at sign-out or restart. With/persistent:yes, Windows reconnects it at the next sign-in. net usewith no arguments lists current mappings and shows whether each is connected.net use Z: /deleteremoves the mapping. The share itself is not affected.
To connect with different credentials, add /user:. If you leave out the password, Windows prompts for it, which keeps it out of the command history.
net use Z: \\server\share /user:DOMAIN\jsmithManaging local accounts with net user
net user works on local accounts. Run on its own, it lists the accounts on the computer. It needs an elevated prompt to change anything.
net user
net user jsmith
net user jsmith * /add
net user jsmith /active:no
net user jsmith /deletenet user jsmithshows one account's details, such as whether it is active, when the password was last set, and which groups it belongs to.- The
*after the name makes Windows prompt for a password without echoing it. This is safer than typing the password into the command. /active:nodisables an account without deleting it. This is the usual choice when someone leaves, because the profile and file ownership stay intact./deleteremoves the account permanently.
To add the account to a group, use net localgroup. For example, net localgroup administrators jsmith /add grants administrator rights.
flowchart TD
A[Need to reach a shared folder or manage an account] --> B{Which task?}
B -->|Connect to a share| C[net use drive: \\server\share]
B -->|Create or change a local account| D[net user]
B -->|Change group membership| E[net localgroup]Common errors
| Message | Likely cause |
|---|---|
| System error 5: Access is denied | The prompt is not elevated, or the account lacks permission on the share |
| System error 53: The network path was not found | Wrong server name, DNS failure, or the server is unreachable |
| System error 1219: Multiple connections not allowed | A session to that server already exists under other credentials. Remove it with `net use \\server\share /delete` |
| System error 85: The local device name is already in use | The drive letter is already mapped. Pick another letter or delete the old mapping |
For error 53, return to the network tools from earlier chapters. Use ping and nslookup to check that the server name resolves and the server responds.
Exercise
A technician maps drive Z: to a share with net use Z: \\server\share /persistent:no. After a restart, Z: is missing. Is this a fault, and how would the technician make the mapping survive a restart?
Show answer
It is expected behavior. /persistent:no makes the mapping last only for the current session. Running the command again with /persistent:yes makes Windows reconnect the drive at each sign-in.