≡ Menu

How to map network drive from command line

We can map a network drive from windows command line using the command net use. Syntax is given below.

net use z: \\remotepc\sharename

The above command maps the drive letter Z: to the network share \\remotepc\sharename. If the logged in user has authorized access to this network share, the above command completes successfully without asking the user to provide username/password. Otherwise it will prompt to supply the credentials of an account authorized to access the share. Upon providing the required credentials, the share gets mapped to the drive Z:

We can also use * instead of Z:. This will automatically pick up the unused drive letter starting from Z:

You can alsp specify username and password in net use command. See examples below.

net use * \\remotepc\share /u:domainname\username password

If you don’t want to type the password in plain text in the windows command line you can specify just the user name. Net use will prompt you for the password.

net use * \\remotepc\share /u:domainname\username

You can use Net use command to map webdav shares also.

Once the network share is mapped, you can start using it like a local drive. You can open the network share in explorer with the drive letter. Open explorer and specify drive letter in the address bar(Z:)

You can also do ‘start Z:’ from command prompt. This would open the network drive in explorer.

Map system drive (C:)  of remote computer

If you have administrator access to the remote computer then you can map the system drive or any other drive of the remote computer with the below command.

net use \\remotepc\C$ /u:username password
9 comments… add one
  • mina

    hi
    i have a problem with this command.when i use this command it does not show me the mapped drive in my computer window.what should i do to monitor the mapped drive?
    thank you

    • Kostas doulas

      Unfortunately you have to edit the registry with a new value key ..enable local connections…google that and you shall get the answer, not so difficult

  • Krishnakumar Balasubramanian

    How to add the folder which has spaces in the share path say \\Kites\Way Back Schedule\ where there is no access for the share to be altered or modified.

  • Jose Alberto

    Is there any way to know which drive letter was assigned after using * ? I´m creating a BAT file and at the end I would like to execute START S: , but not sure which letter was assign.

  • Anthony

    I’m a noob at this.
    If I work from home I have to manually activate all network drives after I connect to my VPN.
    I tried creating a batchfile to activate my network drives after connecting to VPN.
    (e.g. with one drive)

    @echo Create new N: drive mapping
    @net use N: \\Network path /persistent: yes
    :exit
    @pause

    But it doesn’t work,I get this:

    Create new N: drive mapping
    The syntax of this command is:

    NET USE
    [devicename | *] [\\computername\sharename[\volume] [password | *]]
    [/USER:[domainname\]username]
    [/USER:[dotted domain name\]username]
    [/USER:[[email protected] domain name]
    [/SMARTCARD]
    [/SAVECRED]
    [/REQUIREINTEGRITY]
    [/REQUIREPRIVACY]
    [[/DELETE] | [/PERSISTENT:{YES | NO}]]

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

    NET USE [/PERSISTENT:{YES | NO}]

    What am I doing wrong, what should it actually look like to work?
    Thanks in advance!

  • John Holmes

    Put this on the end of the command line
    /persistent:yes
    and the drive is mapped continuously (even after a reboot)

    • John Holmes

      Presuming we want to map a local drive K: to drive D: on a remote computer called SERVER and make it permanent, the correct syntax would be:

      net use k: \\server\d$ /persistant:yes

      ;-)

  • Nav

    How do we map share drive location in execute shell?
    Share drive is windows box and I want to connect to Linux and share the file from windows share drive to Linux box using execute shell jenkins plugging.

    Thank you

  • Nav

    How do we map share drive location in execute shell?
    Share drive is windows box and I want to connect to Linux and share the file from windows share drive to Linux box using execute shell jenkins plugging.

    I don’t want to install any software.

    Is there any commands?
    Thank you

Leave a Comment