Solved

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

Posted on 2014-01-17
2
378 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 46

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

Building an interactive eFuture classroom

Watch and learn how ATEN provided a total control system solution including seamless switching matrix switch, HDBaseT extenders, PDU, lighting control to build an interactive eFuture classroom.

Question has a verified solution.

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

A short article about problems I had with the new location API and permissions in Marshmallow
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

749 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