Solved

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

Posted on 2014-01-17
2
371 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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

771 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