Alan D. Ayers Posted August 15, 2006 Share Posted August 15, 2006 I am very new to AutoIT so far I like what I see. However I cannot find anything on checking if a user belongs to a Windows Group. Any help would be appreciated. Thanks. Alan Link to comment Share on other sites More sharing options...
lod3n Posted August 16, 2006 Share Posted August 16, 2006 Transitioning out of Kix, are we? You could do it with WMI objects, but I've had problems with that not working very well on older machines, and being slow in general. But I stumbled upon another method. Try this: #include <Constants.au3> ; required for StdoutRead ; populate $groupstring with the output of net user /domain ; remove the /domain if you are just interested in local machine groups $foo = Run(@ComSpec & " /c net user "& @username &" /domain", @SystemDir, @SW_HIDE,$STDOUT_CHILD) $groupstring = "" While 1 $groupstring &= StdoutRead($foo) If @error = -1 Then ExitLoop Wend func ingroup($which) if $which = "*" then return 1 $which = stringleft($which, 21) ; net user /domain returns only the first 21 chars of each group $which = "*" & $which if stringinstr($groupstring,$which) then return 1 else return 0 endif endfunc ;example usage if ingroup("Domain Admins") $admin = true else $admin = false endif You could also use part of this code for retrieving the output of a Kix script which enumerated domain group membership. Kix is pretty good at that. [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font] Link to comment Share on other sites More sharing options...
Alan D. Ayers Posted August 16, 2006 Author Share Posted August 16, 2006 That is fabulous thank you very much. It is greatly appreciated. Now if a member is part of the group the application is installed/updated (using runasset for admin priviledges) otherwise the script will just exit. Thank you Thank you Thank you. Link to comment Share on other sites More sharing options...
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