Login Script used for drive mapping

andoss
andoss used Ask the Experts™
on
I've gotten the below script from other threads on EE and modified it to suit my workplace hence my actual knowledge of it isn't that great.
The script will be used to map all network drives for users, it's run via group policy at startup.

My problem is there are alot of users who need to map to their own shared drive aswell as another shared drive. When we were on Novell this was easy to do via exception groups, i'm now looking for a similar solution now that our file server is Windows 2008.

What is happening is that I have all the department groups in the first 'Select Case' statement and they are working fine, however if I add the exception groups to this 'Select Case' then only the first department that a user is a member of gets mapped. (It's mapping exception drives to Q: so it's not that i'm overwriting a previous mapping).
I then created a second 'Select Case' for exception groups and this again works fine however i've just found out there are afew users who are members of exception groups and also the 'VisualPresenter' group. Which means they only get the exception drives.

Is there a more straightforward/better way to do this?
ie. a simple If member VisualPresenter then map X
Even the above in code could fix the problem as I could just have exception drives mapped via if statements outside the 'Select Case', unfortunately not great with VBS myself so don't know how to do this.


On Error Resume Next
 
Set WshNetwork = CreateObject("WScript.Network")
 
DomainString = WshNetwork.UserDomain
UserString = WshNetwork.UserName
 
Set UserObj = GetObject("WinNT://" & DomainString & "/" & UserString)
 
 
 
'Unmaps some drives which it may map so as to prevent errors
WshNetwork.RemoveNetworkDrive "L:",true,true
 
 
 
'Simple mapping of drives other than department shared drive
' WshNetwork.MapNetworkDrive "F:", "\\wfs01\Applications"
 
 
 
 
'Shared drive mapping based on users AD Group, if user is a member of more than one AD Group and drives are same letter the last drive mapped will be given.
For Each GroupObject In UserObj.Groups
strMSG = GroupObject.Name
        Select Case GroupObject.Name
        	Case "RHO_sysadmins"
                	WshNetwork.MapNetworkDrive "H:", "\\wfs01\Home Directories"
			sDrive = "H:\"
			Set oShell = CreateObject("Shell.Application")
			oShell.NameSpace(sDrive).Self.Name = "HO User Home Directories"
		'Case "RHO_finance"
                '	WshNetwork.MapNetworkDrive "U:", "\\wfs01\Home Directories\CATS"
		
 
		Case "RHO_accounts"
			WshNetwork.MapNetworkDrive "L:", "\\wfs02\Departments\Accounts"
		Case "RHO_credits"
			WshNetwork.MapNetworkDrive "L:", "\\wfs02\Departments\Accounts"
		Case "RHO_callcenter"
			WshNetwork.MapNetworkDrive "L:", "\\wfs02\Departments\Callcentre"
			WshNetwork.MapNetworkDrive "J:", "\\wfs02\Departments\Marketing\Telemarketing"
		Case "RHO_BusinessSolutionsGroup"
			WshNetwork.MapNetworkDrive "L:", "\\wfs02\Departments\BSG"
		Case "RHO_executive"
			WshNetwork.MapNetworkDrive "L:", "\\wfs02\Departments\Exec"
		Case "RHO_finance"
			WshNetwork.MapNetworkDrive "L:", "\\wfs02\Departments\Finance"
		Case "RHO_HR"
			WshNetwork.MapNetworkDrive "L:", "\\wfs02\Departments\HR"
		Case "RHO_IT"
			WshNetwork.MapNetworkDrive "L:", "\\wfs02\Departments\IT"
		Case "RHO_knowledge"
			WshNetwork.MapNetworkDrive "L:", "\\wfs02\Departments\Knowledge"
		Case "RHO_marketing"
			WshNetwork.MapNetworkDrive "L:", "\\wfs02\Departments\Marketing"
		Case "RHO_operations"
			WshNetwork.MapNetworkDrive "L:", "\\wfs02\Departments\Operations"
		Case "RHO_prodplan"
			WshNetwork.MapNetworkDrive "L:", "\\wfs02\Departments\Marketing"
		Case "RHO_busexcel"
			WshNetwork.MapNetworkDrive "L:", "\\wfs02\Departments\Quality"
		Case "RHO_sales"
			WshNetwork.MapNetworkDrive "L:", "\\wfs02\Departments\Sales"
		Case "RHO_service"
			WshNetwork.MapNetworkDrive "L:", "\\wfs02\Departments\Service"
		Case "RHO_spareparts"
			WshNetwork.MapNetworkDrive "L:", "\\wfs02\Departments\SpareParts"
		Case "RHO_techsupport"
			WshNetwork.MapNetworkDrive "L:", "\\wfs02\Departments\TechSupport"
		Case "RHO_warehouse"
			WshNetwork.MapNetworkDrive "L:", "\\wfs02\Departments\Warehouse"
		
		'Shared drive mappings for exception groups. ie. Those who need access to another departments shared drive
		Case "RHO_accountsexceptions"
			WshNetwork.MapNetworkDrive "Q:", "\\wfs02\Departments\Accounts"
		Case "RHO_marketingexceptions"
			WshNetwork.MapNetworkDrive "Q:", "\\wfs02\Departments\Marketing"
		Case "RHO_salesexceptions"
			WshNetwork.MapNetworkDrive "Q:", "\\wfs02\Departments\Sales"
		Case "RHO_techsupportexceptions"
			WshNetwork.MapNetworkDrive "Q:", "\\wfs02\Departments\TechSupport"
		
		
	End Select
Next
 
 
'Shared drive mapping for exception groups based on users AD Group, if user is a member of more than one AD Group and drives are same letter the last drive mapped will be given.
For Each GroupObject In UserObj.Groups
strMSG = GroupObject.Name
        Select Case GroupObject.Name
		'Shared drive mappings for exception groups. ie. Those who need access to another departments shared drive
		Case "RHO_accountsexceptions"
			WshNetwork.MapNetworkDrive "Q:", "\\wfs02\Departments\Accounts"
		Case "RHO_marketingexceptions"
			WshNetwork.MapNetworkDrive "Q:", "\\wfs02\Departments\Marketing"
		Case "RHO_salesexceptions"
			WshNetwork.MapNetworkDrive "Q:", "\\wfs02\Departments\Sales"
		Case "RHO_techsupportexceptions"
			WshNetwork.MapNetworkDrive "Q:", "\\wfs02\Departments\TechSupport"
		Case "VisualPresenter Users"
			WshNetwork.MapNetworkDrive "N:", "\\VPS01\VISUALPRESENTER"
	End Select
Next
 
 
 
'Removes the full UNC path from mapped drives under windows explorer and replaces with a shorter name
sDrive = "M:\"
Set oShell = CreateObject("Shell.Application")
oShell.NameSpace(sDrive).Self.Name = "Home Directory"
 
'sDrive = "U:\"
'Set oShell = CreateObject("Shell.Application")
'oShell.NameSpace(sDrive).Self.Name = "CATS"
 
sDrive = "L:\"
Set oShell = CreateObject("Shell.Application")
oShell.NameSpace(sDrive).Self.Name = "Department Share"
 
WScript.Quit

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Author

Commented:
Just realised i forgot to remove the exception group section from the first 'Select Case' please just ignore this, it doesn't create any issues just makes the code messy as those mappings are working there anyway due to the main department drives being mapped first.
I personally prefer to map drives according to OU groups and have seperate scripts for seperate OU's. Means the scripts are more straight foward and a bit simpler, since I am not very good with VBscripts.

However I am sure another expert can help with the VBscript.
Commented:
Apologies the map VisualPresenter line is actually working in either select case, will need to have abit more of a play around.

Please don't waste your time with this question I'll close it and reopen if i can't work it out.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial