How-To Geek

How to Map Network Drives From the Command Prompt in Windows


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


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


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


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


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


That’s all there is to it.

Taylor Gibb is a Microsoft MVP and all round geek, he loves everything from Windows 8 to Windows Server 2012 and even C# and PowerShell. You can also follow him on Google+

  • Published 07/12/12

Comments (15)

  1. Ash

    Nice tip, thanks

  2. Jacqui

    A question: Sometimes, the network drive to my student file folders (I teach K-8) becomes unavailable (I have no idea why). A parent zipped in a command into the Run command and re-established it in five seconds. No reboot. I should have written down what he wrote, but I didn’t. Any idea? This disconnect happens a lot at my school.


  3. r

    That’s nothing new. I do this every time I setup a new users workstation.

  4. Ray Cooke

    I simply have a networked hard drive….simples. Everybody in the family can use it and share whatever they want with the rest of us in the folders I have created such as movies/photos/jokes/music etc. Other users can create folders within these folders but cannot add a folder to the main drive of which I am the admin.
    Doing it this way only 1 pc has to be connected to share files.
    Nobody can access your shares on your machine if it is rurned off !!

  5. Tom C.

    bye, bye HTG!
    Not enough that you are posting definitly stupid, newbie “hints”, you are also censoring user comments about that!

  6. Keith G

    Some of you guys may be advanced geeks that don’t need any new how-to tips. But others of us can use these simple tips. Is it really necessary for you the SHOW OFF YOUR GIANT BRAIN by trashing every article that deals with a topic YOUR GIANT BRAIN already knew. Why not just let it ride so the rest of us can enjoy? Then, maybe some day, in the far distant future, we can achieve GIANT BRAIN status like you.

  7. Mark

    Bye bye, giant brain….

  8. JANIS

    Go Keith Go. U were most polite to the GIANT BRAIN. Manners prevent me voicing what I think of these smart arses who think they know it all

  9. Anora Sabeen

    Agreed with Keith / Janis. I’m work in IT as a systems admin and knowing (let alone remembering) everything geeky in this field is akin to memorizing every error code every car manufacturer ever programmed into their automotive computers… and you only work with BMW’s and Mercedes all day.

    Those with “GIANT BRAINS” rarely ever contribute anything. They are the purist definition of troll you can come too.

  10. Hector

    Does anyone have an answer to Jacqui’s question? the same happens in our nerwork so often.

  11. Taylor Gibb

    @Hector i dont know the answer, there could be a number of reasons you could just drop the connection and recreate it, even write a script to do this automatically.

    Just to set the record straight for everyone else, the only comments that How-To Geek censor are those that contains links as they may be spam.

  12. Charles

    This isn’t all so useful without telling us how to write batch files that launch at startup. I have one running on my computer (Windows 7 Pro), I’ll share in case anybody needs it. (FYI the Persistent command is not very reliable with Windows 7 networking, which is why I have the batch file running at startup)
    Location: C:\Users\$username$\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
    net use T: \\192.168.1.xx\shared Password /user:user /Persistent:Yes
    net use K: \\192.168.1.xx\photo Password /user:user /Persistent:Yes
    net use L: \\192.168.1.xx\music Password /user:user /Persistent:Yes

  13. rangerevo8

    This is useful. Now i could add it to my format routine.
    Did anyone know if there is script for re-add Library as well?


    Why you need to run it every startup since you could use /P to make it Persistent?

  14. rws8258

    For those who, like myself, execute MS-DOS commands less and less by the day (i.e., due to the dumbing-down effects of using the Windows GUI (front-end), here’s a helpful tip to remember… knowing how to do something is rarely more important than knowing how to quickly find the reference.

    IOW, every MS-DOS command (well, at least, those w/ switches and/or parameters) has a “/HELP” switch embedded into it.

    Note: Depending on the version of Windows you’re running (and, thus, which version of MS-DOS is running “underneath” it), “help” could be called by applying one of the following switches: “?”, “/?”, “h”, “/h”, “help”, or “/help”. Also worth noting.., if you get a “help” screen when you actually didn’t want to, then you almost certainly entered an “illegal” switch/parameter.

    So, let’s open a “Command Prompt” window:

    E.g., L-click on the “Windows Orb”, type “cmd” (w/o the quotes, of course)… press

    In the “Command Prompt” window…
    C:\Users\User1>type “net HELP”… press

    Here’s the result…

    The syntax of this command is:

    NET HELP command
    NET command /HELP

    Commands available are:


    NET HELP NAMES explains different types of names in NET HELP syntax lines.
    NET HELP SERVICES lists some of the services you can start.
    NET HELP SYNTAX explains how to read NET HELP syntax lines.
    NET HELP command | MORE displays Help one screen at a time.


    Okay; now, try this…
    C:\Users\User1>type “net HELP USE”… press

    And, here’s the result…

    The syntax of this command is:

    [devicename | *] [\\computername\sharename[\volume] [password | *]]
    [/USER:[dotted domain name\]username]
    [/USER:[username@dotted domain name]
    [[/DELETE] | [/PERSISTENT:{YES | NO}]]

    NET USE {devicename | *} [password | *] /HOME


    NET USE connects a computer to a shared resource or disconnects a
    computer from a shared resource. When used without options, it lists
    the computer’s connections.

    devicename Assigns a name to connect to the resource or specifies
    the device to be disconnected. There are two kinds of
    devicenames: disk drives (D: through Z:) and printers
    (LPT1: through LPT3:). Type an asterisk instead of a
    specific devicename to assign the next available
    \\computername Is the name of the computer controlling the shared
    resource. If the computername contains blank characters,
    enclose the double backslash (\\) and the computername
    in quotation marks (” “). The computername may be from
    1 to 15 characters long.
    \sharename Is the network name of the shared resource.
    \volume Specifies a NetWare volume on the server. You must have
    Client Services for Netware (Windows Workstations)
    or Gateway Service for Netware (Windows Server)
    installed and running to connect to NetWare servers.
    password Is the password needed to access the shared resource.
    * Produces a prompt for the password. The password is
    not displayed when you type it at the password prompt.
    /USER Specifies a different username with which the connection
    is made.
    domainname Specifies another domain. If domain is omitted,
    the current logged on domain is used.
    username Specifies the username with which to logon.
    /SMARTCARD Specifies that the connection is to use credentials on
    a smart card.
    /SAVECRED Specifies that the username and password are to be saved.
    This switch is ignored unless the command prompts for username
    and password.
    /HOME Connects a user to their home directory.
    /DELETE Cancels a network connection and removes the connection
    from the list of persistent connections.
    /PERSISTENT Controls the use of persistent network connections.
    The default is the setting used last.
    YES Saves connections as they are made, and restores
    them at next logon.
    NO Does not save the connection being made or subsequent
    connections; existing connections will be restored at
    next logon. Use the /DELETE switch to remove
    persistent connections.

    NET HELP command | MORE displays Help one screen at a time.

  15. rws8258

    The last post dropped a couple of things…

    In the “Command Prompt” window…
    C:\Users\User1>type “net HELP”… press “Enter”


    Okay; now, try this…
    C:\Users\User1>type “net HELP USE”… press “Enter”

    Sorry for the looooonnggggg post, y’all… ;)

More Articles You Might Like

Enter Your Email Here to Get Access for Free:

Go check your email!