Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Map a drive for a group member

Posted on 2006-07-07
1
Medium Priority
?
261 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 400 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month12 days, 14 hours left to enroll

972 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