Solved

script to map network drive

Posted on 2012-04-08
6
593 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Setting up a Microsoft WSUS update system is free relatively speaking if you have hard disk space and processor capacity.   However, WSUS can be a blessing and a curse. For example, there is nothing worse than approving updates and they just have…
On July 14th 2015, Windows Server 2003 will become End of Support, leaving hundreds of thousands of servers around the world that still run this 12 year old operating system vulnerable and potentially out of compliance in many organisations around t…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now