Jump to content

Recommended Posts

Posted

Hi all

Does anyone know of a way to read the Local Admins group to establish whether or not an installation script will run. I have already implemented a script that adds a domain group to Local Admmins but as we have users from other domains logging on to PC's without any of our Local Admin members I cannot apply it to these machines. This is a critical software update that meeds to be applied to all machines running the software on a given day.

Any help greatly appreciated.

Thanks for looking

[font='Comic Sans MS']Eagles may soar high but weasels dont get sucked into jet engines[/font]

Posted

Thanks for the replies.

Can it not be read through windows? this info is available to anyone logged on (even standard users) via computer managment.

[font='Comic Sans MS']Eagles may soar high but weasels dont get sucked into jet engines[/font]

Posted (edited)

No, you cannot actually read the file. You can request the information from Windows.

Yes via NetGroupGetUsers() winapi function which I need too, but can't make it work.

Code that I've got so far:

#NoTrayIcon
#RequireAdmin
#include <Array.au3>

$aRet = _NetUserGetGroups("Администратор")
_ArrayDisplay($aRet, "Display Array")

Func _NetUserGetGroups($sUsername, $sServer = "")
    Local $tBufPtr = DllStructCreate("ptr")
    Local $tEntriesRead = DllStructCreate("dword")
    Local $tTotalEntries = DllStructCreate("dword")
    Local $aRet = DllCall("Netapi32.dll", "int", "NetUserGetGroups", "wstr", $sServer, "wstr", $sUsername, "dword", 0, "ptr", DllStructGetPtr($tBufPtr), "dword", -1, "ptr", DllStructGetPtr($tEntriesRead), "ptr", DllStructGetPtr($tTotalEntries))
    If $aRet[0] Then Return SetError(1, $aRet[0])
    Local $iEntriesRead = DllStructGetData($tEntriesRead,1)
    Local $pBuf = DllStructGetData($tBufPtr,1)
    Local $sGroupUsersInfo0 = "ptr"
    Local $tGroupUsersInfo0 = DllStructCreate($sGroupUsersInfo0)
    Local $zGroupUsersInfo0 = DllStructGetSize($tGroupUsersInfo0)
    For $i=1 To $iEntriesRead
        $tGroupUsersInfo0 = DllStructCreate($sGroupUsersInfo0, $pBuf+($i-1)*$zGroupUsersInfo0)
        $tGroupName = DllStructCreate("wchar[256]", DllStructGetData($tGroupUsersInfo0,1))
    Next
    DllCall("Netapi32.dll", "int", "NetApiBufferFree", "ptr", $pBuf)
    Return $aRet
EndFunc   ;_NetUserGetGroups
Edited by Ghost1987
Posted

The code below will give you an array list with the member of a group, otherwise return NULL.

#include <Array.au3>

$Administrators = _MemberOfGoups('dan')
_ArrayDisplay($Administrators)

Func _MemberOfGoups($strGroup = "Administrators")
    Local $aMembers = ''
    $objGroup = ObjGet("WinNT://" & @ComputerName & "/" & $strGroup)
    
    If IsObj($objGroup) Then
        For $objMember In $objGroup.Members
            $aMembers &= $objMember.Name & '|'
        Next
        $aMembers = StringSplit(StringTrimRight($aMembers, 1), '|')
    EndIf
    Return($aMembers)
EndFunc

AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line

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
×
×
  • Create New...