[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 592
  • Last Modified:

Mapping multiple network drives from a script file

I'm coming from a Linux background, so to me this should be as easy as making a script file executable and typing ./mapmydrives

I'd like to create a simple app/script/etc which, when launched, automatically maps a series of network drives.  This can be accomplished through Map Network Drive... and putting in a user/pass, but it tends to get tedious as I'm mounting 6 drives at a time.  I'd like to create a series of 5 of these possible scripts so I can mount whichever chunk of drives I need (1-6...7-12...)

Through the command line, I'm able to do this one at a time with 'net use X: \\server\path\ /user:username password' successfully, so I'd hoped it would be simple to chain 6 of those commands together and run them as one script.

For reasons involving other servers, it won't work to make 5 different windows logins and 5 windows login scripts...I'm tied to using a single username for Windows.  I'm not running separate domains...everything exists within a single workgroup, so the net use command seems logical to me.  I'm just not certain how to create a file or .exe in Windows that would do this would significant programming.  Thanks for any help.
0
kwinke
Asked:
kwinke
  • 3
  • 2
1 Solution
 
GoldwingCommented:
make a .cmd or .bat file

start notepad

e: \\server1\path\ /user:username password
f: \\server2\path\ /user:username password
g: \\server3\path\ /user:username password
h: \\server4\path\ /user:username password
i: \\server5\path\ /user:username password
j: \\server6\path\ /user:username password

and save this file at "netlogon.bat" or "netlogon.cmd"

Doubleclick on it..
0
 
GoldwingCommented:
err.. mistake

make a .cmd or .bat file

start notepad

net use e: \\server1\path\ /user:username password
net use f: \\server2\path\ /user:username password
net use g: \\server3\path\ /user:username password
net use h: \\server4\path\ /user:username password
net use i: \\server5\path\ /user:username password
net use j: \\server6\path\ /user:username password

and save this file at "netlogon.bat" or "netlogon.cmd"

Doubleclick on it..
0
 
GoldwingCommented:
Here you have a example logon script "netlogon.bat" file



@ECHO OFF
CLS
echo **************************************************************
echo **                  Microsoft 2000 SERVER                   **
echo **         Copyright(c) Microsoft Corp., 1990-2002          **
echo **                                                          **
echo **           You are logged on Contrason Network            **
echo **                                                          **
echo **              Unauthorised use is prohibited              **
echo **************************************************************
REM These commandlines will be driven to all users.
net time \\contra01 /set /yes

net use p: \\Contra01\Applications
net use s: \\contra01\Setup
net use r: \\contra01\Data
net use t: \\contra01\Temp

if exist u: goto ok
net use u: /home
:ok

net use lpt1: \\contra01\laserjet1
net use lpt2: \\contra01\hpoffice
net use lpt3: \\contra01\laserjet2


net use
exit
0
 
narmaniCommented:
I have several workstations that need mappings to a Novell resource with whoever logs on - if this helps;
Using Notepad, create: logon.cmd

net use F: \\server\path [password] /USER:[username]

one line for each needed mapping; if your user is "Bill" and the password is "Library", you would type:

net use F: \\server\path library /USER:Bill
net use G: \\server\path library /USER:Bill
and so on ...

THEN, (on the W2K machines);

* Run MMC [Start -> Run -> MMC]
* File -> Add/Remove Snapin
* ADD -> Group Policy -> ADD
* Finish
* Close "Stand alone snapin" window
* OK at Add/Remove Snapin Window
* "Local Computer Policy" will now be listed in the left pane of "Console1"
* Select the [+] next to Local Computer Policy
* Select the [+] next to Computer Configuration
* Select the [+] next to Windows Settings
* Highlight "Scripts (Startup/Shutdown)"
* In the right hand pane, you will see Startup and Shutdown options.  
* Select the Start option, and ADD the path to your logon.cmd file
* Perform the SAME function beneath "User Configuration"

As a note, I also run a "logoff.cmd" file that simply /d's all of the net use commands in the logon file ...

Hope this helps.

namani
0
 
narmaniCommented:
I have several workstations that need mappings to a Novell resource with whoever logs on - if this helps;
Using Notepad, create: logon.cmd

net use F: \\server\path [password] /USER:[username]

one line for each needed mapping; if your user is "Bill" and the password is "Library", you would type:

net use F: \\server\path library /USER:Bill
net use G: \\server\path library /USER:Bill
and so on ...

THEN, (on the W2K machines);

* Run MMC [Start -> Run -> MMC]
* File -> Add/Remove Snapin
* ADD -> Group Policy -> ADD
* Finish
* Close "Stand alone snapin" window
* OK at Add/Remove Snapin Window
* "Local Computer Policy" will now be listed in the left pane of "Console1"
* Select the [+] next to Local Computer Policy
* Select the [+] next to Computer Configuration
* Select the [+] next to Windows Settings
* Highlight "Scripts (Startup/Shutdown)"
* In the right hand pane, you will see Startup and Shutdown options.  
* Select the Start option, and ADD the path to your logon.cmd file
* Perform the SAME function beneath "User Configuration"

As a note, I also run a "logoff.cmd" file that simply /d's all of the net use commands in the logon file ...

Hope this helps.

namani
0

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now