未加星标

How to Map Network Drives From the Command Prompt in Windows

字体大小 | |
[系统(windows) 所属分类 系统(windows) | 发布者 店小二05 | 时间 2017 | 作者 红领巾 ] 0人收藏点击收藏

How to Map Network Drives From the Command Prompt in Windows

Mapping a network drive to a shared folder from windows’ graphic interface isn’t hard. But if you already know the network path for the shared folder, you can map drives a lot quicker using the Command Prompt.

Mapping a drive to a network share assigns that share a drive letter so that it’s easier to work with. We’ll be using the net use command in Command Prompt to map a network drive for this tutorial. You can also use the same command in PowerShell if you prefer.

To map a network drive, type the following command and then hit Enter:

net use DRIVE: PATH

DRIVE is the drive letter you want to use and PATH is the full UNC path to the share. So, for example, if we wanted to map drive letter S to the share \\tower\movies, we’d use the following command:

net use s: \\tower\movies
How to Map Network Drives From the Command Prompt in Windows
How to Map Network Drives From the Command Prompt in Windows

If the share to which you’re connecting is protected with some sort of authentication, and you’d rather not type in the credentials every time you open the network drive, you can add the user name and password to the command with the /user: switch. For example, if we wanted to connect the same share from above, but with the username HTG and the password CrazyFourHorseMen, we’d use the command:

net use s: \\tower\movies /user:HTG CrazyFourHorseMen
How to Map Network Drives From the Command Prompt in Windows

By default, mapped drives are not persistent. If we map drives using the commands we’ve talked about so far, the mapped drives would disappear when you restarted your computer. If you’d rather those mapped drives stick around, you can make them persistent by usingthe /persistent switch. The switch works as a toggle:

/persistent:Yes: Makes the connection you’re currently creatingpersistent. Future connections you make using the command during the same session are also persistent (you don’t need to keep using the switch) until you use the /persistent:No switch to turn it off. /persistent:No: Turns off the persistency toggle. Future connections you make are not persistent until you turn the toggle back on.

So, essentially, you could type something like the following command:

net use s: \\tower\movies /user:HTG CrazyFourHorseMen /persistent:Yes

And the drive map would be persistent. All future mapping you create (even if you don’t use the /persistent:Yes switch) will also be persistent until you turn it off using the /persistent:No switch.


How to Map Network Drives From the Command Prompt in Windows

If you ever need to delete a mapped network drive, all you have to do is specify the drive letter and add the /delete switch. For example, the following command would delete the drive mapping we assigned to drive S:

net use s: /delete
How to Map Network Drives From the Command Prompt in Windows

You can also use the asterisk as a wildcard should you ever want to delete all your mapped drives in one go:

net use * /delete
How to Map Network Drives From the Command Prompt in Windows

And that’s all there is to it. Once you get used to using the command, you’ll find it a lot quicker than clicking through File Explorer’s interface especially if you work with mapped drives often.

本文系统(windows)相关术语:三级网络技术 计算机三级网络技术 网络技术基础 计算机网络技术

主题: WindowsPowerShell
tags: use,persistent,drive,command,switch,network,using,net,drives,share
分页:12
转载请注明
本文标题:How to Map Network Drives From the Command Prompt in Windows
本站链接:http://www.codesec.net/view/561428.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 系统(windows) | 评论(0) | 阅读(37)