Home Work Tips and Tricks Mapping a drive in Windows using the command line
Mapping a drive in Windows using the command line PDF Print E-mail
Work - Windows Tips and Tricks
Written by mbrock   
Thursday, 22 May 2008 22:28

If you do any IT work with Windows, you may find a time when you need to map a network drive to a drive letter through the command line. For instance, you may need to write a batch file that maps a drive to a server, copies some files, and then deletes the mapped drive.

Mapping a drive like this is done using the net command - or more specifically the net use command. The net use command connects a computer to or disconnects a computer from a shared resource, or displays information about computer connections.

 

To map a network drive to a letter use net use with the following syntax:

net use [drive letter] \\server\path /USER:domain\username
For example:
net use x: \\myserver\c$\documents /USER:mydomain\mbrock

and now the x: drive on your machine points to the \\myserver\c$\documents folder.

And to delete a mapped network drive with net use:

net use <drive letter> /delete
For example:
net use x: /delete

now you no longer have an x: drive.

The net use command has other options too. The complete syntax options of net use are displayed below.

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

Used without parameters, net use shows a list of network connections.

I recommend that you try experimenting around with the net command. It can do some interesting things.

(This has been tested in Windows 2000, Windows XP, and Windows Vista.)

 
Comments (1)
?/HOME Parameter
1 Friday, 08 January 2010 04:08
Alan Stewart
I cannot find anywhere an explanation of the effect of the /HOME parameter. Any suggestions?

Add your comment

Your name:
Your email:
Your website:
Subject:
Comment:
  The word for verification. Lowercase letters only with no spaces.
Word verification:
mbrock.com
This site, it's contents, and "The Original Web Empire"
Copyright © 1999 - 2010 mbrock.com. All Rights Reserved.