如何在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.

从Windows的图形界面将网络驱动器映射到共享文件夹并不难。 但是,如果您已经知道共享文件夹的网络路径,则可以使用命令提示符更快地映射驱动器。

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.

将驱动器映射到网络共享会分配共享一个驱动器号的文件,以便于使用。 我们将在命令提示符中使用net use命令映射本教程的网络驱动器。 如果愿意,还可以在PowerShell中使用相同的命令。

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

要映射网络驱动器,请键入以下命令,然后按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:

DRIVE是要使用的驱动器号,PATH是共享的完整UNC路径。 因此,例如,如果我们要将驱动器号S映射到共享\\ tower \ movies,则可以使用以下命令:

net use s: \\tower\movies

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:

如果要连接的共享受到某种身份验证的保护,而您不想在每次打开网络驱动器时都键入凭据,则可以使用/user:将用户名和密码添加到命令中/user:开关。 例如,如果我们想从上方连接相同的共享,但使用用户名HTG和密码CrazyFourHorseMen,则可以使用以下命令:

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

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 using the /persistent switch. The switch works as a toggle:

默认情况下,映射驱动器不是持久性的。 如果我们使用到目前为止已经讨论过的命令来映射驱动器,则当您重新启动计算机时,映射的驱动器将消失。 如果您希望这些映射的驱动器始终存在,则可以使用/persistent开关使它们持久/persistent 。 开关用作拨动开关:

  • /persistent:Yes: Makes the connection you’re currently creating persistent. 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:是:使您当前正在创建的连接保持不变。 在同一会话期间使用该命令建立的将来连接也将保持持久状态(无需继续使用该开关),直到使用/persistent:No开关将其关闭为止。

  • /persistent:No: Turns off the persistency toggle. Future connections you make are not persistent until you turn the toggle back on.

    / persistent:否:关闭持久性切换。 除非重新打开切换开关,否则以后建立的连接不会持久。

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.

驱动器映射将是持久的。 将来创建的所有映射(即使您不使用/persistent:Yes开关)也将保持不变,直到使用/persistent:No开关将其关闭。

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:

如果您需要删除映射的网络驱动器,则只需指定驱动器号并添加/ delete开关即可。 例如,以下命令将删除我们分配给驱动器S的驱动器映射:

net use s: /delete

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

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.

这就是全部。 一旦习惯了使用该命令,就会发现它比单击File Explorer的界面要快得多-特别是如果您经常使用映射的驱动器。

翻译自: https://www.howtogeek.com/118452/how-to-map-network-drives-from-the-command-prompt-in-windows/

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值