Hello,
I have a log on script that I need to tweak to be able to map a drive letter to multiple network shares based on the users' group membership. I assign 2 default drive mappings to all users: R: for the Departments' Restricted Folder, and P: for the Company Public Folder. S: is mapped for users who require a specific network share and who belong to a specific group. The remaining network shares should be mapped for users who belong to other groups/departments, starting with T:.
This is simple for those users who are members of one group/department, however, I have numerous users who are members of more than one group/department and need a way to automatically map the network shares to the next available drive letter, starting from T:. For instance, Bob is a member of the Bulk/Bakery, Store1, and DeptMgr groups/departments. Bob needs to access each departments' network share, and therefore would have T:, U:, and V: mapped to each respective share.
The attached code snippet is a portion of the code from my log on script. Currently I need to add the While loop to each Select Case conditional statement for each group/department in order to properly map the shares to an available drive letter, but I'm hoping to shorten and optimize the code so that all groups are cycled through until they are all processed. Currently I have 20 groups/departments.
Thanks for your assistance.
==================================
'Map the available drive letters starting from T: to other Network Shares and create the Desktop Icons
Set objFS=CreateObject ("Scripting.FileSystemObject")
Set colDrives=objFS.Drives
letter=Asc("t")
For Each GroupObj In UserObj.Groups
Select Case GroupObj.Name
Case "Bulk Bakery"
While objFS.DriveExists(Chr(letter)+":")
letter=letter+1
Wend
strDrvLtr = UCASE(Chr(letter)) & ":"
WSHNetwork.MapNetworkDrive strDrvLtr, "\\<SERVER>\Public\Bulk",True
Set objShortCut = WSHShell.CreateShortcut(strDesktopFolder & "\Bulk Public Folder.lnk")
objShortCut.TargetPath = strDrvLtr
objShortCut.Description = "Bulk Public Folder"
objShortCut.Save
I have a log on script that I need to tweak to be able to map a drive letter to multiple network shares based on the users' group membership. I assign 2 default drive mappings to all users: R: for the Departments' Restricted Folder, and P: for the Company Public Folder. S: is mapped for users who require a specific network share and who belong to a specific group. The remaining network shares should be mapped for users who belong to other groups/departments, starting with T:.
This is simple for those users who are members of one group/department, however, I have numerous users who are members of more than one group/department and need a way to automatically map the network shares to the next available drive letter, starting from T:. For instance, Bob is a member of the Bulk/Bakery, Store1, and DeptMgr groups/departments. Bob needs to access each departments' network share, and therefore would have T:, U:, and V: mapped to each respective share.
The attached code snippet is a portion of the code from my log on script. Currently I need to add the While loop to each Select Case conditional statement for each group/department in order to properly map the shares to an available drive letter, but I'm hoping to shorten and optimize the code so that all groups are cycled through until they are all processed. Currently I have 20 groups/departments.
Thanks for your assistance.
==================================
'Map the available drive letters starting from T: to other Network Shares and create the Desktop Icons
Set objFS=CreateObject ("Scripting.FileSystemObject")
Set colDrives=objFS.Drives
letter=Asc("t")
For Each GroupObj In UserObj.Groups
Select Case GroupObj.Name
Case "Bulk Bakery"
While objFS.DriveExists(Chr(letter)+":")
letter=letter+1
Wend
strDrvLtr = UCASE(Chr(letter)) & ":"
WSHNetwork.MapNetworkDrive strDrvLtr, "\\<SERVER>\Public\Bulk",True
Set objShortCut = WSHShell.CreateShortcut(strDesktopFolder & "\Bulk Public Folder.lnk")
objShortCut.TargetPath = strDrvLtr
objShortCut.Description = "Bulk Public Folder"
objShortCut.Save