Solved

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

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

Free camera licenses with purchase of My Cloud NAS

Milestone Arcus software is compatible with thousands of industry-leading cameras for added flexibility. Upon installation on your My Cloud NAS, you will receive two (2) camera licenses already enabled in the software. And for a limited time, get additional camera licenses FREE.

Question has a verified solution.

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

Suggested Solutions

A short article about a problem I had getting the GPS LocationListener working.
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.
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.
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…

932 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now