Question Locked

Mapping Network files with a batch file

0 helpful
13 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi,
There are about 15 drives on the server, and when i set up a new computer it takes a very long time to go and map them all manually aka right click my comp ect.

So i was wandering if anyone knew how i could write a batch file whcih maps all these drives for me.

Any help very much appreciated

Thanks alex

13 replies

by bizzo

You can use the "net use" command.

e.g.
net use x: \\\ /persistent:YES

by bart777

All you need to do is create a login.bat file that uses the Net Use statement.

Ex:
net use x: \\server\sharename
net use y: \\server1\sharename

After you create the file you and add it to the profile tab of each user through active directory.

You might want to open a DOS window and do a net use /? so that you can see all of the switches available to you.

Good luck

by alex_boothby

am i being stupid i put this exactly

net use h: \\server1\workspace

and it maps nothing!

by bart777

If you open the DOS window you should be able to just type NET USE

Once you do that it should show you a list of list of connected drives.

Does this work for you??

by bizzo

When you run this from the command line are you getting any errors?

If your sharename has spaces in, then the path will need to be quoted.

by alex_boothby

no errors it just comes up then dissapears! and there are no space it is just \\server1\workspace

well one of them is i was just testing it on that one first

thanks for your help

by bizzo

How are you running the net use command?
From Start/Run, or from a cmd window?

I'd suggest running it from a cmd window to see if any errors appear.

When you say "it just comes up and then disappears", I don't know what you mean.

by alex_boothby

it says net is not a recognisable internal or external command

cheers for the help

by alex_boothby

It says it "net" is not recognisable as a internal or extrernal command

im baffaled

by bart777

You should get something. Even NET offers a list of sub commands.
I only have 2 other things left.
1) Set you directory to the windows directory. Then try the net use command again. If that fails CD to the system32 directory.
2) if that doesn't work then you may need to look at another scripting language. Something like KIX32. Go to www.kixtart.org for more info.

I don't see any reason why it wouldn't work in the windows directory though

OOOOH,
1 other thing to check. Try opening the CMD prompt from the programs menu. I have seen some things like C# and VB setup some strange version of the DOS window that never seems to work correcly.

That's all I have in My bag of tricks.

Best of luck.

by ben.rattigan

into your startup folder or into your user profile in Active Directory. Save the file as filename.vbs first. Replace servername for the host name of your server and sharenames for the individual shares you want to map, replace the drive letters with those you want to use.

Dim objNet
dim strUserName
Dim net
Dim WSHShell
Dim removedrives
Dim remPrinter, strPrintPath

Set WSHShell = CreateObject("WScript.Shell")

'Map Network Drives

Set objNet = CreateObject("Wscript.Network")
strUserName =objNet.UserName

objNet.MapNetworkDrive "s:", "\\servername\sharename1"
objNet.MapNetworkDrive "u:", "\\servername\sharename2"
objNet.MapNetworkDrive "k:", "\\servername\sharename3"

WSCript.Quit

This discussion is closed to new replies.