Solved

Fix login.vbs to map multiple drives as well as map a drive based on group membership.

Posted on 2014-01-17
2
375 Views
Last Modified: 2014-04-22
This is a .vbs script we want to use for our login script. How can you modify the code so that you can have multiple mapped drives and so that you can map folders depending on the department the user is in. Right now it will only map 1 drive, the other mappings arent working.



On Error Resume Next

'Remove ALL Mapped Drives
On error resume next 
Set WshNetwork = WScript.CreateObject("WScript.Network") 
Set oDrives = WshNetwork.EnumNetworkDrives 
For i = 0 to oDrives.Count - 1 Step 2 
WshNetwork.RemoveNetworkDrive oDrives.Item(i),true,true 
Next 


Set objSysInfo = CreateObject("ADSystemInfo")
Set objNetwork = CreateObject("Wscript.Network")

strUserPath = "LDAP://" & objSysInfo.UserName
Set objUser = GetObject(strUserPath)

For Each strGroup in objUser.MemberOf
    strGroupPath = "LDAP://" & strGroup
    Set objGroup = GetObject(strGroupPath)
    strGroupName = objGroup.CN

'Map All Users To This Drive Letter
   objNetwork.MapNetworkDrive "Z:", "\\server2\a la mode\WinTOTAL"
   objNetwork.MapNetworkDrive "W:", "\\server2\a la mode\"

    Select Case strGroupName
      
        Case "Accounting" 
            objNetwork.MapNetworkDrive "Q:", "\\server2\Quickbooks"

        Case "Engineering" 
            objNetwork.MapNetworkDrive "Y:", "\\WIN-7TBJVQLALJM\Engineering"


    End Select
Next

Open in new window

0
Comment
Question by:GTechForce
2 Comments
 
LVL 45

Accepted Solution

by:
Craig Beck earned 500 total points
ID: 39790419
Which drive gets mapped?

Have you investigated using Group Policy Preferences instead of a VBS script.  It's far better to use GPP than VBS scripts.
0
 

Author Closing Comment

by:GTechForce
ID: 40016561
I've been using login scripts for years, but after researching group policy mappings and the fact you can target specific users/computers as well as even CPU speed to assign mappings too, this makes it far superior to VBS scripts.

Thanks for the suggestion!
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

777 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