PayneBack3 0 Posted May 19, 2010 Im trying to create a script to install software only if the user is in s specific group,but it does not seem to work,everytime it sas that im not a member. Please Assist. $Groupmember=Runwait ("ifmember.exe /v Admin") ;check for membership of Admin-Users if Not $Groupmember Then MsgBox (16, "Error!", "User is not a member of Admin-Users") Exit (1) EndIf Share this post Link to post Share on other sites
water 2,392 Posted May 19, 2010 If you want to check membership for an Active Directory group you can use the AD UDF (for download please see my signature). Function _AD_IsMemberOf() will do what you need. 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
PayneBack3 0 Posted May 19, 2010 Hi water thanks for the response i'm new on Autoit can you please show me an example how to check membership ? Thanks. Share this post Link to post Share on other sites
water 2,392 Posted May 19, 2010 Hi water thanks for the responsei'm new on Autoitcan you please show me an example how to check membership ?Thanks.When you download the AD UDF there is an example script for every function. Please see file _AD_IsMemberOf.au3The script first gets a list of all groups the user is a member of and then checks if the user is a member of the first group. This always returns true but the script checks every other possible return codes and therefore should give you an idea how to solve your problem. 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
Country73 6 Posted May 19, 2010 (edited) Im trying to create a script to install software only if the user is in s specific group,but it does not seem to work,everytime it sas that im not a member. Please Assist. $Groupmember=Runwait ("ifmember.exe /v Admin") ;check for membership of Admin-Users if Not $Groupmember Then MsgBox (16, "Error!", "User is not a member of Admin-Users") Exit (1) EndIf Just so you have an example for using "ifmember". I still bounce over to it once in a while. #include <Array.au3> #include <Constants.au3> Local $ifMem = "\\xena.statestr.com\LOGON\KansasCity\ifmember.exe" Local $foo = Run(@ComSpec & " /c " & $ifMem & " /l",@SystemDir,@SW_HIDE,$STDERR_CHILD + $STDOUT_CHILD) Local $line Local $aGroups ;Read all details from IFMEMBER While 1 $line = StdoutRead($foo) If @error Then ExitLoop If Not $line = "" Then $aGroups &= StringUpper($line) WEnd ;Split each group to handle individually Local $mSplit = StringSplit($aGroups,@LF) ;Extract first of each line so only Group Name remains Local $Output For $a = 1 To $mSplit[0] $Output = StringReplace($mSplit[$a],"USER IS A MEMBER OF GROUP ","") _ArraySwap($mSplit[$a],$Output) Next ;Sort Groups alphabetically so search is quicker, display for example _ArraySort($mSplit,0,1) _ArrayDisplay($mSplit,'Groups') Exit You can now search through the Array to look for the specific group membership. Hope that works out for you as well. [Edit] I run it in this manner since I generally have my script to look for several different group memberships to run different things. Edited May 19, 2010 by Country73 If you try to fail and succeed which have you done?AutoIt Forum Search Share this post Link to post Share on other sites