Sign in to follow this  
Followers 0
stefanba

IF/Else query for local groups

6 posts in this topic

Hello,

sorry my english is not so good.... :P

i need a if/else function with a query to localgroups on an W2k3 Terminalserver.

The Server runs in a Domain and on the server are 3 localgroups with domainusers included

dependent from the loginusername i want to start a different program with autoit.

please can you help me ???

Share this post


Link to post
Share on other sites



dependent from the loginusername i want to start a different program with autoit.

Look under Run in the help file, is this what you mean?

Share this post


Link to post
Share on other sites

i mean:

if userA in LocalGroup "Applicatipon1_User" then start Application1

else start Application2

the run command i know, but not the query for localgroups

Share this post


Link to post
Share on other sites

I want to do the same thing, this is what i found :

$Name = InputBox("Group", "Login", "", "", 100, 100, 100, 100)
If @error Then Exit
If $Name = "" Then Exit
Local $objUser = ObjGet("WinNT://" & @computername & "/" & $Name)
For $oGroup in $objUser.Groups
    MsgBox(4096, "Groups", $oGroup.Name, 10)
Next

But :P it works on local account, not on DomainUser. When i change "@computername" with "@logondomain" it give me DomainGroup, not LocalGroup ...

Share this post


Link to post
Share on other sites

i have see thois post via boardquery...in my case bad... :P

Share this post


Link to post
Share on other sites

Look at that :P it works for me

#Include <Array.au3>
$oMyError = ObjEvent("AutoIt.Error","MyErrFunc"); Install a custom error handler
Local $objDomain = ObjGet("WinNT://" & @ComputerName & "" )
$answer = InputBox("Question", "Quel User ???", "Nom du USER", "", _
    -1, -1, 0, 0)

$objUser = ObjGet("WinNT://" & @LogonDomain & "/" & $answer)

Dim $filter[1] = ["group"]
$objDomain.Filter = $filter

local $LocalGroup =""
;~ Recupère les groupes locaux
For $aUser In $objDomain

    $objGroup = ObjGet("WinNT://" & @ComputerName & "/" & $aUSer.Name)


        For $objMember In $objGroup.Members()
            If $objMember.Name = $objUser.Name Then
                MsgBox(0,"",$objUser.Name & " est un membre de " & $objGroup.Name & @CRLF)
                ExitLoop
            EndIf
        Next
Next



;COM Error function
Func ComError()
    If IsObj($oMyError) Then
        $HexNumber = Hex($oMyError.number, 8)
        ConsoleWrite($oMyError.scriptline & '  $HexNumber = ' & $HexNumber & "Windescription is: " & $oMyError.description & "|" & $oMyError.windescription  & @lf);### Debug Console
        SetError($HexNumber)
    Else
        SetError(1)
    EndIf
    Return 0
EndFunc;==>ComError

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0