HumperHard Posted March 2, 2009 Share Posted March 2, 2009 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 More sharing options...
Developers Jos Posted March 2, 2009 Developers Share Posted March 2, 2009 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 More sharing options...
HumperHard Posted March 2, 2009 Author Share Posted March 2, 2009 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 More sharing options...
HumperHard Posted March 3, 2009 Author Share Posted March 3, 2009 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 Link to comment Share on other sites More sharing options...
weaponx Posted March 3, 2009 Share Posted March 3, 2009 Use a variable. Link to comment Share on other sites More sharing options...
erik7426 Posted March 3, 2009 Share Posted March 3, 2009 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 More sharing options...
HumperHard Posted March 3, 2009 Author Share Posted March 3, 2009 Use a variable.Good call.... that worked... wow I really need to brush up on my programming skills....Thanks Link to comment Share on other sites More sharing options...
HumperHard Posted March 3, 2009 Author Share Posted March 3, 2009 $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 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