Jump to content

List Local User Accounts


Recommended Posts

I cant seem to list all the local user accounts on a machine. Can someone point me in the right direction ->

Here is what I have so far (it doesnt work tho):

; #########################################################################################
; # List users on the computer
; #########################################################################################

$strComputer = @ComputerName

DIM $Users

$colAccount = ObjGet("WinNT://" & $strComputer & "")
$objUsers = $colAccount.Filter ("user", $Users)
$arrayCount = _ArrayMaxIndex($objUsers)

MsgBox (4096, "Test", "ArrayCount:" & $arrayCount);test message

For $i=0 To $arrayCount Step 1
    MsgBox ( 4096, "User Accounts", "User Name:" & $Users )
Next
Link to comment
Share on other sites

  • Developers

Try:

$oMyError = ObjEvent("AutoIt.Error","MyErrFunc"); Install a custom error handler 
Local $objDomain = ObjGet("WinNT://" & @ComputerName & "" )
Dim $filter[2] = ["user"]
$objDomain.Filter = $filter

For $aUser In $objDomain
   ConsoleWrite($aUSer.Name & "|" & $aUSer.Description & @LF)
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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Try:

$oMyError = ObjEvent("AutoIt.Error","MyErrFunc"); Install a custom error handler 
Local $objDomain = ObjGet("WinNT://" & @ComputerName & "" )
Dim $filter[2] = ["user"]
$objDomain.Filter = $filter

For $aUser In $objDomain
   ConsoleWrite($aUSer.Name & "|" & $aUSer.Description & @LF)
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

Thanks that worked!!

Link to comment
Share on other sites

I would like to output all the names in one msgbox or similar instead of one msgbox for each user. Can someone point me in the right direction?

Thanks

$oMyError = ObjEvent("AutoIt.Error","MyErrFunc"); Install a custom error handler 
Local $objDomain = ObjGet("WinNT://" & @ComputerName & "" )
Dim $filter[2] = ["user"]
$objDomain.Filter = $filter

$list = ""

For $aUser In $objDomain
    $list = $list & $aUSer.Name & "|" & $aUSer.Description & @CRLF
Next

MsgBox(0,"User Accounts",$list)

;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
Link to comment
Share on other sites

$oMyError = ObjEvent("AutoIt.Error","MyErrFunc"); Install a custom error handler 
Local $objDomain = ObjGet("WinNT://" & @ComputerName & "" )
Dim $filter[2] = ["user"]
$objDomain.Filter = $filter

$list = ""

For $aUser In $objDomain
    $list = $list & $aUSer.Name & "|" & $aUSer.Description & @CRLF
Next

MsgBox(0,"User Accounts",$list)

;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

Thats basically what I did.. Thanks!

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...