Solved

Map a drive for a group member

Posted on 2006-07-07
1
246 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
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

821 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