jazzyjeff 5 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 Share this post Link to post Share on other sites
water 2,387 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 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - WikiOutlookEX (NEW 2020-12-15 - Version 1.6.3.1) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2020-06-27 - Version 1.3.2.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - WikiTask Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - WikiTutorials:ADO - Wiki, WebDriver - Wiki Share this post Link to post Share on other sites
JohnOne 1,603 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. Share this post Link to post Share on other sites
jazzyjeff 5 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. Share this post Link to post Share on other sites