Solved

Map a drive for a group member

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
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…

706 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

12 Experts available now in Live!

Get 1:1 Help Now