Automating map of network drives

J

John Doue

Hi,

I frequently need to map 3 partitions (d:, e: and c: in that order) of a
local network machine, respectively to m:, n:, and z: from my workstation.

Is there a way to automate this task via a batch file, just by
specifying the network name of the external machine?

Then, when I am finished, is it possible to disconnect those mapped
partitions via a batch file?

Thanks
 
P

Pegasus [MVP]

John Doue said:
Hi,

I frequently need to map 3 partitions (d:, e: and c: in that order) of a
local network machine, respectively to m:, n:, and z: from my workstation.

Is there a way to automate this task via a batch file, just by specifying
the network name of the external machine?

Then, when I am finished, is it possible to disconnect those mapped
partitions via a batch file?

Thanks

Try this:
@echo off
net use /persistent:no
net use X: \\PC1\Share1
net use Y: \\PC2\Share2
etc.

To disconnect the shares, use commands like this one:
net use X: /d

To see the many uses of the net.exe command, type this at the Command
Console:
net /?
net help
net use /?
net help use
 
J

Jean-Paul Darcis

Thanks, but now, I have a problem with the names of the partitions I
want to map. It appears there are naming restrictions to the mapped
partitions, which are applicable in a batch file and which are not using
explorer, tools, map.

Could you please share (pun intended) some light on those conventions?

Thanks
 
P

Pegasus [MVP]

Jean-Paul Darcis said:
Thanks, but now, I have a problem with the names of the partitions I want
to map. It appears there are naming restrictions to the mapped partitions,
which are applicable in a batch file and which are not using explorer,
tools, map.

Could you please share (pun intended) some light on those conventions?

Thanks

I am not aware of any share naming restrictions. If a name is valid for a
folder then it is valid for a share. If you think otherwise, can you give an
example?
 
S

Shenan Stanley

Jean-Paul Darcis said:
Thanks, but now, I have a problem with the names of the partitions I
want to map. It appears there are naming restrictions to the mapped
partitions, which are applicable in a batch file and which are not
using explorer, tools, map.

Could you please share (pun intended) some light on those
conventions?
Thanks

Use Quotation Marks around names with spaces/long names..

net use m: "\\myserver\this is my share" /persistent:no
 
J

John Doue

Pegasus said:
I am not aware of any share naming restrictions. If a name is valid for
a folder then it is valid for a share. If you think otherwise, can you
give an example?

Yes, I do think otherwise. I kept getting error 67 when trying this:

use net z: \\acer-or\acer-or (c)

where acer-or is the name of the machine on the network and acer-or (d)
the name of drive d: on that machine.

I was about to post a help request after stumbling for hours on this
error 67 and researching the Internet about it, when it occurred to me
that the name of the drive might be a problem since the command is typed
in what amounts to DOS remnants (and I go back to DOS times ...).

Since I am the network administrator, I changed the drive share name to
aceror(d) and my batch file worked instantly.

Shenan Stanley's post, which I read after I changed the shared drive's
name seems to confirm there is a convention.

To unify the name policy of the machines on the network, I decided to
rename all mapped drives according to the model aceror(d) (which is
explicit enough for me) to avoid such problems.

So it does look Shenan Stanley hit it on the nail. A pity this naming
convention (which may seem obvious enough once you put back this problem
in a broader context, but only then) is not clearly spelled out on the
MS pages I visited (granted, I may have missed some :)). A pity too
that error 67 is kind of a pork barrel, not very helpful.

Thanks for your attention.
 
P

Pegasus [MVP]

John Doue said:
Yes, I do think otherwise. I kept getting error 67 when trying this:

use net z: \\acer-or\acer-or (c)

where acer-or is the name of the machine on the network and acer-or (d)
the name of drive d: on that machine.

I was about to post a help request after stumbling for hours on this error
67 and researching the Internet about it, when it occurred to me that the
name of the drive might be a problem since the command is typed in what
amounts to DOS remnants (and I go back to DOS times ...).

Since I am the network administrator, I changed the drive share name to
aceror(d) and my batch file worked instantly.

Shenan Stanley's post, which I read after I changed the shared drive's
name seems to confirm there is a convention.

To unify the name policy of the machines on the network, I decided to
rename all mapped drives according to the model aceror(d) (which is
explicit enough for me) to avoid such problems.

So it does look Shenan Stanley hit it on the nail. A pity this naming
convention (which may seem obvious enough once you put back this problem
in a broader context, but only then) is not clearly spelled out on the MS
pages I visited (granted, I may have missed some :)). A pity too that
error 67 is kind of a pork barrel, not very helpful.

Thanks for your attention.

The convention of surrounding file or folder names with double quotes when
they have embedded spaces has been around ever since long file names became
permissible, i.e. since Windows 95 was introduced. That was almost 15 years
ago!
 
J

John Doue

Pegasus said:
The convention of surrounding file or folder names with double quotes
when they have embedded spaces has been around ever since long file
names became permissible, i.e. since Windows 95 was introduced. That was
almost 15 years ago!

I am not saying otherwise, on the contrary! I started 25 years ago and
when on the command line, this is still not embedded in my thinking! Ok,
this base of users is shrinking every day, but have mercy :).
 
B

boatman312

John said:
I am not saying otherwise, on the contrary! I started 25 years ago and
when on the command line, this is still not embedded in my thinking! Ok,
this base of users is shrinking every day, but have mercy :).
I'm jumping in a little late, but...

Isn't the syntax "net use //..." , not "use net //..."
 
J

John Doue

boatman312 said:
I'm jumping in a little late, but...

Isn't the syntax "net use //..." , not "use net //..."

Of course! Just a typo, but worth correcting ...
 
J

John John - MVP

John said:
Of course! Just a typo, but worth correcting ...

And of course the above solidus are wrong... Give 'em' a couple of
stiff drinks until they lean the other way...

John
 
J

John Doue

John said:
And of course the above solidus are wrong... Give 'em' a couple of
stiff drinks until they lean the other way...

John

This is a testimony to the value of double-checking one's posts ...
Followed your advice, and had a stiff one ... Good advice!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top