Solved

script to map network drive

Posted on 2012-04-08
6
600 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

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…
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

803 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