?
Solved

Mapping multiple network drives from a script file

Posted on 2003-03-15
5
Medium Priority
?
586 Views
Last Modified: 2007-12-19
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
Comment
Question by:kwinke
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 7

Expert Comment

by:Goldwing
ID: 8144681
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
 
LVL 7

Accepted Solution

by:
Goldwing earned 300 total points
ID: 8144689
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
 
LVL 7

Expert Comment

by:Goldwing
ID: 8144700
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
 

Expert Comment

by:narmani
ID: 8149831
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
 

Expert Comment

by:narmani
ID: 8149840
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
In the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed o…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month14 days, 1 hour left to enroll

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question