Sign in to follow this  
Followers 0
HumperHard

List Local User Accounts

8 posts in this topic

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

Share this post


Link to post
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

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
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!!

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Use a variable.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Use a variable.

Good call.... that worked... wow I really need to brush up on my programming skills....

Thanks

Share this post


Link to post
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!

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