Mapping network drive using bat file

  • WELCOME TO THE NEW SERVER!

    If you are seeing this you are on our new server WELCOME HOME!

    While the new server is online Scott is still working on the backend including the cachine. But the site is usable while the work is being completes!

    Thank you for your patience and again WELCOME HOME!

    CLICK THE X IN THE TOP RIGHT CORNER OF THE BOX TO DISMISS THIS MESSAGE

timmy1376

SatelliteGuys Pro
Original poster
May 20, 2004
698
0
Manhattan, KS
No problems mapping a network drive using a .bat file, but I cannot figure out for the life of me how to get the bat file to map to a folder in the share. I have a share called software and 20 folder in it called Lab 1 all the way to Lab 20

for example:
I do map network drives

\\IP.IP.IP.IP\software\Lab 14

and it works great, but trying to do that in a bat file, nothing happens

\\IP.IP.IP.IP\software

works great in the bat file.

Anyone know how to get directly to that Lab 14 folder using a bat file?
 
net use x: \\ip.ip.ip.ip\share
x: being the desired drive letter to assign.

You can also delete the mapping

net use x: /delete
or
net use x: /delete /y
to delete and answer yes if a message requiring confirmation comes up.

There are other more exotic ways to do it with different scripting languages.
 
Should work fine even with a sub-dir of the shared directory

example:

net use x: \\ip.ip.ip.ip\share\subdir

Just tested quicky and it works fine for me. What OS are we talking here? I assumed windows.

If you wanted to get real fancy you could put a loop or similar in the batch file and map all 20 lab directories with just a couple lines in the batch file.
Edit:
OH, wait, do your lab directories look like this?

Lab 14
not
Lab14
?

The space is getting ya. Try this

net use x: "\\ip.ip.ip.ip\share\subdir stuff"
 
even better

Set oShell = Createobject("wscript.shell") <enter>
Set oNet = CreateObject("Wscript.Network") <enter>
oNet.MapNetworkDrive "v:", "\\name of computer\name of share", True, "username", "password" <enter>
if same computer copy line to \name of share"
if new computer drive type the full line and username and password

this will allow you to map network drives with different user names and passwords and you can customize it to fit as many shares as needed
 

Users Who Are Viewing This Thread (Total: 0, Members: 0, Guests: 0)

Who Read This Thread (Total Members: 1)

Latest posts