如何通过批处理文件来创建映射驱动器 [英] How to create MAP Drive by batch file
问题描述
通常我要创建映射驱动器,其中i指定计算机和用户凭据。现在我想知道,我们可以编写一个批处理文件,这将创建映射驱动器,并在那里我提供如PC和文件夹位置和用户凭据等,我得到了一个如下的所有细节,但我认为这不是其中一个我需要。
请指导我。谢谢
often i have to create map drive where i specify machine and user credential. now i like to know can we write a batch file which will create map drive and where i provide all details like pc and folder location and user credentials etc. i got one as follows but i think this is not one which i require. please guide me. thanks
net use \\<network-location>\<some-share>\ password /USER:username
@echo Create new L: drive mapping
@net use L: \\network path /persistent:yes
@echo Create new K: drive mapping
@net use K: \\network path /persistent:yes
:exit
如果我做这样......那么它的工作原理
if i do this way...then does it work
net use y: \\192.168.7.15\$D\testfolder password /USER:username /PERSISTENT:YES
请指导.....语法好吗?
please guide.....the syntax is ok?
推荐答案
牟的查询答案:如果一个映射驱动器称为中的Z该PC存在,那么会发生什么?我们可以写批处理文件一样,如果一个特定的映射驱动器存在然后断开并再次重新连接。
Answer of the Mou's query: If a map drive called Z exist in that pc then what will happen? can we write batch file like if a specific map drive exist then disconnect it and reconnect it again.
这个问题的解决方案是,你可以简单地映射的共享不分配驱动器号。然后它只能由其远程UNC路径映射匿名。这样,您还可以通过specifiying只有它的远程名称删除映射。
The solution of this problem is that You can simply map the share without assigning a drive letter. It is then mapped anonymously, only by its remote UNC path. This way you can also remove the mapping by specifiying only its remote name.
@echo off
net use \\192.168.7.15\testfolder password /user:domain\username /savecred /p:yes
REM Do your stuffs here.....
net use \\192.168.7.15\testfolder /delete
托马斯的查询的答:如何断开连接并通过批处理文件连接映射驱动器。
Answer of the Thomas's query: How to disconnect and connect map drive by batch file.
如果您只是想断开并重新连接映射驱动器,这样做:
If you simply want to disconnect and re-connect a map drive, do like this:
@echo off
net use z: /delete
net use z: \\192.168.7.15\testfolder password /user:domain\username /savecred /p:yes
这篇关于如何通过批处理文件来创建映射驱动器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!