Solved

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

Posted on 2014-01-17
2
380 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:Brad Nelson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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:Brad Nelson
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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
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 …
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

617 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