Solved

Map a drive for a group member

Posted on 2006-07-07
1
256 Views
Last Modified: 2008-01-09
Hi,

I have the following entered into a script:

If IsMemberOf("LandMaster") Then
      MapDrive "f:","\\dc01\data"
End If

However the script runs without error but the drive is not mapped.  Can somebody tell me where I may be going wrong.

Many thanks
0
Comment
Question by:glennturner1
[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
1 Comment
 
LVL 1

Accepted Solution

by:
EHodapp earned 100 total points
ID: 17078089
If you are doing this as part of a login script, the code below should work:



Set oShell=CreateObject("WScript.Shell")
Set WN=WScript.CreateObject("WScript.Network")

'Get Username
UserName=oShell.ExpandEnvironmentStrings("%USERNAME%")

'Write Username to event log for debugging
WriteLog 4,"[VBScript.VBS] UserName:" & UserName

' *** Be sure to put your domain name in the line below, between the slashes
Set usr=GetObject("WinNT://DomainNameGoesHere/" & UserName & ",user")

For Each grp in usr.groups
      Select Case UCASE(grp.name)
      Case "LANDMASTER"
            Oshell.LogEvent 4,"[VBScript] Mapping Drive for Group: " + grp.name
            WN.MapNetworkDrive "F:", "\\dc01\data"
            
      Case Else
            'For Debugging, write users group memberships to event log
            Oshell.LogEvent 4,"[VBScript] GroupMember:-" + grp.name
      End Select
Next
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month7 days, 11 hours left to enroll

632 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