Map to drive on server with bat file

batchnetworking

I have a web server that I want to map a drive to it. I want to do this in a .bat file. Pseudo ->

Check if a drive at an ip address has been mapped to a local drive.
If it has then progress with a reference to the drive
If not map to a local drive and then progress with a reference to the drive

Is this possible and if so how can I achieve it?

Best Answer

You do not need to check if a mapping exists if the same drive letter is always used, the net use command will simply fail if it is unsuccessful at remapping with a system error 85.

e.g:

net use x: \\10.1.2.3\Share