Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Windows server 2003 drive mapping & logon scripts

Posted on 2006-11-04
12
Medium Priority
?
915 Views
Last Modified: 2012-05-05
Hi can somebody help me with examples of logon VB script for Wondows 2003 & drive mapping.

I will try keep this as simple as possible! I have active directory set up with an domain name called "convert.com".

DHCP is set up to allocate IP to my clients & DNS for the domain name with forwerders for my ISP DNS address.
Everything is well with the clients loging on to the domain and i have shared folders on the server which can be accessed by typing in \\servername\\sharename.

I want to map my folder shares so that when a user logs on the shares appear under "my computer" on the clients.
I know how to map a drive by using the "Map Network drive" option on windows 2003 but how do i make them appear under "My Computer" on the clients on the network???????????

should they automatically appear under "My Computer"??? on the clients after they have been mapped on the server or d0 you have to search for them via my network places????



Next issue,

I have for example two users on my for example username , jreid & Jhankin
Both these users also have a folder on the server \\servername\\jreid   & \\servername\\jhankin

I would like these users to have their shared folders mapped as a network drive under "My computer" on the client when they log on.
I would like their folder to appear as drive H for example along with some other folders mapped too.

To do this do I understand I need a logon VB script which is created in note pad, saved with a VBS ext and placed in the group policy , users, windows settings,
logon scripts in Active directory OU.
Can anyone provide me with an example of a logon script i can use to test this???
if im using a logon script does that mean that the shares are mapped and shared by the script alone or do you still need to share the folders and map as drives as well???????

Any help much appreciated




0
Comment
Question by:softley
  • 7
  • 5
12 Comments
 
LVL 20

Expert Comment

by:Lazarus
ID: 17875521
on error resume next
Dim WshNetwork
Set WshNetwork = WScript.CreateObject("WScript.Network")

' This removes a previously mapped drive on Z
WshNetwork.RemoveNetworkDrive "Z:"

' This ads a Shared Folder mapped drive on Z
WshNetwork.MapNetworkDrive "Z:", "\\SERVERNAME\SHAREDFOLDERNAME"

WScript.Quit
0
 
LVL 20

Expert Comment

by:Lazarus
ID: 17875525
And yes, you still need to have the Folders shared. but the above script will map those shares to the client when they log in. Just place the Login script into your Netlogon file on your server and put the name of the vbs script into you Users AD profile
0
 

Author Comment

by:softley
ID: 17875646
Ok, what about my first question in terms of drive mapping without a script?

where do you add to AD profile?

do you need a differn't script for each user?? for example each user will have their own mapped drive.


can you just keep adding extra shares in the script,,,,  example below

This removes a previously mapped drive on Z
WshNetwork.RemoveNetworkDrive "Z:"

' This ads a Shared Folder mapped drive on Z
WshNetwork.MapNetworkDrive "Z:", "\\SERVERNAME\SHAREDFOLDERNAME"

This removes a previously mapped drive on Z
WshNetwork.RemoveNetworkDrive "H:"

' This ads a Shared Folder mapped drive on H
WshNetwork.MapNetworkDrive "H:", "\\SERVERNAME\SHAREDFOLDERNAME"
0
Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

 
LVL 20

Expert Comment

by:Lazarus
ID: 17876952
You can just keep adding shares to the script...

You place the VBS script name in the AD profile of each user.

Active Directory Users and Computers   ->   User  -> Right click properties   ->   Profile Tab   ->   login Script:

If you need to set a diffrent path for each person you can do it alot of ways. Either a different login script for each. (not my preferenece), or by group.

Example of script using Group mapping by AD's OU:
_____________________________________________________________________
Option Explicit
Dim objNetwork, objUser, CurrentUser
Dim strGroup

Const Admin_Group = "cn=oly_users_admin"
Const Managers_Group = "cn=oly_users_manager"
Const Accounting_Group = "oly_users_accounting"
Const Estimate_Group = "cn=oly_users_estimate"
Const Design_East_Group = "cn=oly_design_east"
Const Design_West_Group = "cn=oly_design_west"
Const All_Users_Group = "cn=oly_users_all"

Set objNetwork = CreateObject("WScript.Network")
' Forces script to skip errors (rem below line to see errors)
on error resume next

Dim WshNetwork
Set WshNetwork = WScript.CreateObject("WScript.Network")
' Set all drives to be removed here.
WshNetwork.RemoveNetworkDrive "m:"
WshNetwork.RemoveNetworkDrive "n:"
WshNetwork.RemoveNetworkDrive "o:"
WshNetwork.RemoveNetworkDrive "p:"
WshNetwork.RemoveNetworkDrive "q:"
WshNetwork.RemoveNetworkDrive "r:"
WshNetwork.RemoveNetworkDrive "s:"
WshNetwork.RemoveNetworkDrive "t:"
WshNetwork.RemoveNetworkDrive "u:"
WshNetwork.RemoveNetworkDrive "v:"
WshNetwork.RemoveNetworkDrive "w:"
WshNetwork.RemoveNetworkDrive "x:"
WshNetwork.RemoveNetworkDrive "y:"
WshNetwork.RemoveNetworkDrive "z:"

Set objUser = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://" & objUser.UserName)
strGroup = LCase(Join(CurrentUser.MemberOf))

' SETTING ALL NETWORKDRIVES THAT ARE AVAILABLE FOR EVERY USER
objNetwork.MapNetworkDrive "q:", "\\server\catalouges"
 objNetwork.MapNetworkDrive "r:", "\\server\job photos"
 objNetwork.MapNetworkDrive "t:", "\\olysbs\office documents"
 objNetwork.MapNetworkDrive "y:", "\\server\public"
 objNetwork.MapNetworkDrive "z:", "\\olysbs\Users\"  & objNetwork.UserName

' SETTING THE PRINTERS, APPARANTLY FOR EVERYONE THE SAME !
Set net = CreateObject("WScript.Network")
net.AddWindowsPrinterConnection "\\olysbs\chris", "Chris's Printer"
net.AddWindowsPrinterConnection "\\olysbs\frank", "Frank's Printer"
net.AddWindowsPrinterConnection "\\olysbs\shop", "Shop Printer"
net.AddWindowsPrinterConnection "\\olysbs\11x17", "11x17 Printer"
net.AddWindowsPrinterConnection "\\olysbs\invoice1", "Main Invoice Printer"
net.AddWindowsPrinterConnection "\\olysbs\invoice2", "BU Invoice Printer"
net.AddWindowsPrinterConnection "\\olysbs\office", "Main Office Printer"
net.AddWindowsPrinterConnection "\\server\design east", "Design East"
net.AddWindowsPrinterConnection "\\server\design east", "Design West"
net.AddWindowsPrinterConnection "\\server\lee", "Lee's Printer"

' EXTRA DRIVES FOR SPECIFIC GROUP

if InStr(strGroup, Admin_Group) or instr(strGrooup, Managars_Group) or instr(strGrooup, Estimate_Group) then
   objNetwork.MapNetworkDrive "m:", "\\olysbs\slg shared "
   objNetwork.MapNetworkDrive "o:", "\\olysbs\job costing"
end if

if InStr(strGroup, Admin_Group) or instr(strGrooup, Managars_Group) then
   objNetwork.MapNetworkDrive "v:", "\\olysbs\manager"
end if

if instr(strGroup, Managars_Group) or instr(strGroup, Design_East_Group) or  =instr(strGroup,Design_West_Group) then
   objNetwork.MapNetworkDrive "x:", "\\server\sprink slick"
end if

if instr(strGrooup, Managars_Group)
  objNetwork.MapNetworkDrive "n:", "\\server\drawings"
end if

if InStr(strGroup, Admin_Group) then
 objNetwork.MapNetworkDrive "p:", "\\olysbs\slg"
 objNetwork.MapNetworkDrive "s:", "\\server\slic"
 objNetwork.MapNetworkDrive "u:", "\\olysbs\hr"
 objNetwork.MapNetworkDrive "w:", "\\olysbs\accounting"
end if
_____________________________________________________________________


It sounds after re-reading this though that perhaps you might actually want to Re-Direct you users folders to the server rather than there desktops. It would appear to them as if it's actaully on there desktop but all there documents would be on the server or where ever you want them to reside.
But if this doesn't do it for you, perhaps it would be better though, if you tell me what you are trying to accomplish in a bit more detail. then I can come up with the best answer to fit your purpose.
0
 
LVL 20

Expert Comment

by:Lazarus
ID: 17876978
I'm really sorry, but I seem confused now on this question.. Are you refering to making Home Folders for your users?

This was from oBdA in a previously answered question:
The home folder is basically for the user to save his files in, so that they can be backed up properly.
You could of course map the drive manually, but it's easier to make use of this feature. You'll notice, for example, that there are two environment variables set (%Homedrive% and %Homepath%) that point to the user's home drive; some application use this information. Or take the folder redirection GPO: there's a default setting to redirect the "My Documents" folder to the user's home folder. All this will only work if the home folder is properly defined in the user's properties.
It's best practice to use it.
0
 

Author Comment

by:softley
ID: 17878180
Ok you have answered my question in differn't ways but to make sure here's what i was asking!

1: if you have shared folders on server which have been mapped using the map network drive option,,,,,,without using a script .
When somebody/user logs on to the server via their client machine where will these mapped shared folders appear on the client??
IE under "my computer" or under my network places??


2: on my server i have 4 folders which are shared to every user on the network

eg. \\servername\\photos  \\servername\\tools \\servername\\office \\servername\\disks

In addition to the folders which every user on the network has access to , each user also has thier own personal shared folder \\servername\\their log on name

eg \\servername\\jhankin.



So when the user logs on they need to see all the shared folders mapped under "my computer" on the client + their own shared folder but not any of the other users own personal folder.
Each users personal folder needs to be given the same drive letter,
for example Jhakin logs on and his personal folder is H drive
Jreid logs on and his personal folder is H drive


I understand you need a script for this to map the shared folders on log on , I understand you need to save the script on the logon script and point the users profile to the script.

Do we need an individual script for each user to do the above or can we use a group script.


Hope that make my question easyier to understand??  


 
0
 

Author Comment

by:softley
ID: 17878209
PS were is the netlogon file ?? do you paste the script into the file?
what if you need more than one script do you keep pasting into the netlogon file?

Thank for you time on this
0
 
LVL 20

Expert Comment

by:Lazarus
ID: 17882249
I think this should do it for you. Try it and let me know.


Set objNetwork = CreateObject("WScript.Network")
' Forces script to skip errors (rem below line to see errors)
on error resume next

Dim WshNetwork
Set WshNetwork = WScript.CreateObject("WScript.Network")

WshNetwork.MapNetworkDrive "H:", "\\servername\photos"
WshNetwork.MapNetworkDrive "I:", "\\servername\tools"
WshNetwork.MapNetworkDrive "J:", "\\servername\office"
WshNetwork.MapNetworkDrive "K:", "\\servername\disks"

'maps user drive
Dim shell, username

set shell = WScript.CreateObject( "WScript.Shell" )
username = shell.ExpandEnvironmentStrings("%USERNAME%")

IF IsMember ("MapP") Then
         MapDrive "P:", "\\servername\sharedfolder\" & username & "$"
End IF
0
 

Author Comment

by:softley
ID: 17886010
ok but what about my other questions?

1 if you have shared folders on server which have been mapped using the map network drive option,,,,,,without using a script .
When somebody/user logs on to the server via their client machine where will these mapped shared folders appear on the client??
IE under "my computer" or under my network places??

2: where is the netlogon file ?? do you paste the script into the file?
what if you need more than one script do you keep pasting into the netlogon file?

3: also would the above script work for a group??, Do I need to add the user name in the script section BELOW + their personal folder or will this covered in the script??


'maps user drive
Dim shell, username

set shell = WScript.CreateObject( "WScript.Shell" )
username = shell.ExpandEnvironmentStrings("%USERNAME%")

IF IsMember ("MapP") Then
         MapDrive "P:", "\\servername\sharedfolder\" & username & "$"
End IF
0
 
LVL 20

Accepted Solution

by:
Lazarus earned 2000 total points
ID: 17886830
1. A shared folder does not automaically map to a client without a client running a login script. but a Client computer can see a shared folder on the server by navigating to:
My Network Places
   Entire Network
      Microsoft Windows Network
          NAME OF DOMAIN
             SERVER NAME

2. The login script goes into your servers Netlogon Folder. The folder is located in:
C:\WINDOWS\SYSVOL\sysvol\DOMAINNAME\scripts
Place your login.vbs script inside of that folder

3. The First script I gave you works with Groups, the second is if you have the same mappings for everyone except the user folder. The second script does not need the username changed. you just have to make sure that the name of the Shared User Folder is the same as the user name that logs in... ie. D:\SERNAME\PROFILES\softley


You may want to learn about VB Scripting. Here are some links that may help:

Scripting: Your First Steps
http://www.microsoft.com/technet/scriptcenter/topics/beginner/firststeps.mspx

Frequently Asked Questions about Logon Scripts
http://www.rlmueller.net/LogonScriptFAQ.htm

Logon Script info at LabMice.net
http://labmice.techtarget.com/scripting/logonscripts.htm

0
 

Author Comment

by:softley
ID: 17887671
thanks
0
 
LVL 20

Expert Comment

by:Lazarus
ID: 17890717
I hope I was able to actually answer your questions and set you on the right track...
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Many of us need to configure DHCP server(s) in their environment. We can do that simply via DHCP console on server or using MMC snap-in on each computer with Administrative Tools installed in a network. But what if we have to configure many DHCP ser…
ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Loops Section Overview

926 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