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 al
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