Solved

script to map network drive

Posted on 2012-04-08
6
605 Views
Last Modified: 2012-08-14
Can someone tell me what syntax i should use  on the login script to map network drive? The server is windows 2003. if they have something already map to that drive than i want  the new map drive to overwrite.


thanks
0
Comment
Question by:officertango
6 Comments
 
LVL 12

Assisted Solution

by:Sandeep
Sandeep earned 167 total points
ID: 37822432
Please see to below link which should drive you through how to do mapping of network drive.

http://homepages.ius.edu/jholly/a247/labs/logonscript.htm
0
 
LVL 17

Assisted Solution

by:Anuroopsundd
Anuroopsundd earned 166 total points
ID: 37822434
below script map \\localhost\i$ as S drive. if s: exist it will disconnect it and then final line of code will map the drive.

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objNetwork = CreateObject("WScript.Network")
strLocalDrive = "S:"
strRemoteShare = "\\localhost\I$"
if(ObjFSO.DriveExists(strLocalDrive)) then
objNetwork.RemoveNetworkDrive strLocalDrive, True, True
end if
objNetwork.MapNetworkDrive strLocalDrive, strRemoteShare
0
 
LVL 31

Accepted Solution

by:
Frosty555 earned 167 total points
ID: 37822436
Here's a login script I've used for a client in the past. It includes a bit of logic that lets me map special drives for specific user accounts, and also map a "personal" shared drive for each employee.

All users get the H:\ drive mapped to their personal shared folder
Two special users - jsmith and janedoe, get a special folder mapped to the G:\ drive.
Everybody else gets the F:\ drive mapped to a different shared folder

NETLOGON.BAT:
if (%username%)==(jsmith) goto jsmith
if (%username%)==(janedoe) goto janedoe
goto otherusers

REM jsmith doesn't have access to the F drive. Make sure it isn't mapped
:jsmith
net use F: /delete
net use G: /delete
net use G:  \\SERVER1\CompanyPublic
goto allusers

REM janedoe doesn't have access to the F drive. Make sure it isn't mapped
:janedoe
net use F: /delete
net use G: /delete
net use G:  \\SERVER1\CompanyPublic
goto allusers

REM everybody else gets the F drive mapped
:otherusers
net use F: /delete
net use F:  \\SERVER1\Data
goto allusers

REM all users get the H drive mapped to their personal storage folder
:allusers
net use H: /delete
net use H: \\SERVER1\UserShares\%username%
goto exit

:exit

Open in new window

0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

Author Comment

by:officertango
ID: 37822514
Ok, i got the syntax down but the script will not start automatically when i login to domain. i can start it manually and it works fine. i put the login.bat in c:\windows\sysvol\domain name\scripts and it does not launch automatically. what am i doing wrong?


thanks
0
 
LVL 5

Expert Comment

by:gortm001
ID: 37822672
You either have to specify the script to run in a Group policy, or put the name in the logon script field in the users profile tab in Active directory. If you do the latter, do not put a full path in there, because it by default uses the scripts path. So in your case, just add login.bat in the field.

So I would say it just depends on the amount of users you have to edit which way you prefer.

Hope this helps,

KG
0
 

Author Closing Comment

by:officertango
ID: 37856766
na
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

The HP utility "HP Lights-Out Online Configuration Utility for Windows Server 2003/2008" could be of great use when it comes to remotely configure a HP servers ILO WITHOUT rebooting the server. We would only need to create and run scripts using thi…
Numerous times I have been asked this questions that what is it that makes my machine log on so slow, there have been cases where computers took 23 minute exactly after taking password and getting to the desktop. Interesting thing was the fact th…

839 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