Search code examples
windowsbatch-filewindows-7network-drive

How to map a network drive inside a batch


My users are use to map network drives.

I developed a tools, which use a network drive i:.

Problem : I may overlap a user-defined drive.

How can I open a dos batch file which will define a new network drive for its own usage but that will not change the network drives visible by the user?


Solution

  • you can use

    pushd \\server\share
    

    it will map a drive on the first available letter

    the drive will be disconnect when running popd

    Current directory may be obtained through the environement variabble %cd%.