jazzyjeff Posted May 26, 2010 Posted May 26, 2010 Hi, I am using the following script to map network drives based on user group membership: expandcollapse popup#include<AD.au3> DriveMapDel ("H:") DriveMapDel ("I:") DriveMapDel ("J:") DriveMapDel ("K:") DriveMapDel ("L:") DriveMapDel ("M:") DriveMapDel ("N:") DriveMapDel ("O:") DriveMapDel ("P:") DriveMapDel ("Q:") DriveMapDel ("R:") DriveMapDel ("S:") DriveMapDel ("V:") DriveMapDel ("W:") DriveMapDel ("X:") DriveMapDel ("Y:") DriveMapDel ("Z:") Global $aUser, $sFQDN_Group, $sFQDN_User, $iResult ; Open Connection to the Active Directory _AD_Open() ; Get the Fully Qualified Domain Name (FQDN) for the current user $sFQDN_User = _AD_SamAccountNameToFQDN() ; Get an array of group names (FQDN) that the current user is immediately a member of $aUser = _AD_GetUserGroups(@UserName) $sFQDN_Group = $aUser[1] ; Check the group membership of the specified user for the specified group $iResult = _AD_IsMemberOf($sFQDN_Group, $sFQDN_User) Select Case $iResult = "Domain Admins" DriveMapAdd("M:","\\app2\K5-Staff") DriveSetLabel("M:\","M Drive - Apps") DriveMapAdd("N:","\\app2\K5-Common") DriveSetLabel("N:\","N Drive - Common Apps") DriveMapAdd("T:","\\staffshare1\departmentshares$\Technology") DriveSetLabel("T:\","T Drive - Technology") DriveMapAdd("X:","\\techstore1\toolbox$") DriveSetLabel("X:\","X Drive - Toolbox") DriveMapAdd("Y:","\\techstore1\toolbox$\Deployment Drive\Elementary") DriveSetLabel("Y:\","Y Drive - Deployment") DriveMapAdd("Z:","\\StaffStore2\Userdata$\" &@UserName) DriveSetLabel("Z:\","Z Drive - " & @UserName & " - Home Directory") EndSelect ; Close Connection to the Active Directory _AD_Close() The drive mapping part works fine, but the labels work for some of the drives and not others. Why is this? I am guessing my code is ok if it works for some of the drives, but maybe there is a problem with the "DriveSetLabel" function? I have attached an image to help understand what I mean. The drives should read: M Drive - Apps N Drive - Common Apps T Drive - Technology etc.. Thanks in advance for any help. Jeff
water Posted May 26, 2010 Posted May 26, 2010 Are you sure you want to do the "DriveSetLabel" in your login script? I understand that "DriveSetlabel" writes the volume label to the disk. But that's something you do when you create the disk. That means once and not at every logon. I recommend to remove the "DriveSetLabels" from your login script and set the labels once manually. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
JohnOne Posted May 26, 2010 Posted May 26, 2010 Donr know about the function but you might try adding some error checking For instance DriveSetLabel() returns 1 if success and 0 if fail, as does DriveMapDel() I would start with checking those return values. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
jazzyjeff Posted May 26, 2010 Author Posted May 26, 2010 Water, Thanks for the response. I understand what you are saying about the drive label being used once. I am currently using a Kix script with the MapDrive UDF that achieves the results. Unfortunately, the script takes a long time to finish executing (almost a minute). The AutoIT script finishes in seconds. The time it completes the task is pretty critical as the teachers and students at my school assume everything is going to be ready as soon as they log in. We set the labels on the drive because it made it easier for the users to see what drive they were looking at. Now that we have implemented, it will be tough to take away, as I can imagine a few people complaining. I am going to try a suggestion in this article. http://www.autoitscript.com/forum/index.php?showtopic=22041 I'll post a response when I get to test it.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now