How to create MAP Drive by batch file

后端 未结 2 348
青春惊慌失措
青春惊慌失措 2021-01-14 10:38

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

相关标签:
2条回答
  • 2021-01-14 11:01

    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
    
    0 讨论(0)
  • 2021-01-14 11:07

    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
    
    0 讨论(0)
提交回复
热议问题