How to create MAP Drive by batch file

二次信任 提交于 2019-12-01 10:59:08

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.

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

I presume your testfolder is shared then do like this:

net use z: \\192.168.7.15\testfolder password /user:domain\username /savecred /p:yes
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!