Solved

script to map network drive

Posted on 2012-04-08
6
596 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
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

This may not be a text book method to resolve VSS backup issues but it seemed to have worked on few of the Windows 2003 servers we had issues while performing a Volume Shadow Copy backup. If you have issues while performing a shadow copy backup usin…
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…
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.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

943 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

5 Experts available now in Live!

Get 1:1 Help Now