Solved

Map a drive for a group member

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Restricting text box entry from \/:?<>"| 9 86
Excel VBA combine two working workbooks 8 53
How to debug this code 7 61
Convert VB6 MSXML2.ServerXMLHTTP process to C# 2 46
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…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
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…

776 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