| Mapping a drive in Windows using the command line |
|
|
|
| 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 to delete a mapped network drive with net use: net use <drive letter> /delete For example:now you no longer have an x: drive.net use x: /delete The net use command has other options too. The complete syntax options of net use are displayed below. 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.)
|





