How to Map Network Drives From the Command Prompt in Windows

image

You most probably know how to assign a drive letter to a network share, but that’s not impressive. Why not change that by mapping your network shares from the command prompt?

Mapping a Network Drive in Windows

To map a network drive from the command prompt we have to use the net use command. If you already know the UNC path to your share, then you’re good to go–the following command will map the movies share to the S drive.

net use s: \\tower\movies

image

Your share will probably be protected with some sort of authentication, and the user switch allows us to specify a username and password. The following example assumes:

  • The username you authenticate with on the remote machine is HTG
  • The password for the HTG account is Pa$$word

net use s: \\tower\movies /user HTG Pa$$word

image

The previous commands are not persistent, this means that the minute you reboot your PC the shares will disappear from your computer. To get the shares to survive a reboot, you need to add use the persistent switch. Note that you can also just use /P instead.

net use s: \\tower\movies /P:Yes

image

If you ever need to delete a mapped network drive, you can use the delete switch after specifying it’s drive letter.

net use s: /Delete

image

Alternatively, if you ever want to get rid of all the shares on your machine, you can use the wildcard character instead of specifying a specific drive letter.

net use * /Delete

image

That’s all there is to it.

Advertisements
Posted in CLI