Jump to content

Get a list of all users accounts


Recommended Posts

I have a project in which I need to list all user accounts on a system (ASPNET, Help assistant etc.).

So far I have tried control userpasswords2 with numerous get text's on the SysListView32. I have not yet found a way to get a TEXT list. I also tried the computer management snap in, but of course that also uses the SysListView32.

Anyone have any ideas?

Link to comment
Share on other sites

Run(@ComSpec & " /k NET USER")

:)

Yes, very nice. Gives a bit less info than the methods I have already tried and is just as useless in getting a TEXT output that I can do anything with. But, thank you for the info :)

Link to comment
Share on other sites

Yes, very nice. Gives a bit less info than the methods I have already tried and is just as useless in getting a TEXT output that I can do anything with. But, thank you for the info :)

Run(@ComSpec & " /k NET USER > C:\Temp\UserList.txt")

If you're going to let a little SysListView32 control scare you off, your options are limited...

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Run(@ComSpec & " /k NET USER > C:\Temp\UserList.txt")

If you're going to let a little SysListView32 control scare you off, your options are limited...

:)

Scared off???? LOL easy there. Simply a tad out of my element in the software end. I'm putting together a quick script to give basic info on my customers systems that will be exported to a text file and printed after their repairs are finished. Generally I concern myself with such things as bad power supplies, corrupted data recovery etc.

The only thing scarey about the software end of computer repair is how dull it is :)

Thanks for the help, this should work well enough.

Link to comment
Share on other sites

; Generated by AutoIt Scriptomatic

$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"

$Output=""
$Output = $Output & "Computer: " & $strComputer  & @CRLF
$Output = $Output & "==========================================" & @CRLF
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_UserAccount", "WQL", _
                                          $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

If IsObj($colItems) then
   For $objItem In $colItems
      $Output = $Output & "AccountType: " & $objItem.AccountType & @CRLF
      $Output = $Output & "Caption: " & $objItem.Caption & @CRLF
      $Output = $Output & "Description: " & $objItem.Description & @CRLF
      $Output = $Output & "Disabled: " & $objItem.Disabled & @CRLF
      $Output = $Output & "Domain: " & $objItem.Domain & @CRLF
      $Output = $Output & "FullName: " & $objItem.FullName & @CRLF
      $Output = $Output & "InstallDate: " & WMIDateStringToDate($objItem.InstallDate) & @CRLF
      $Output = $Output & "LocalAccount: " & $objItem.LocalAccount & @CRLF
      $Output = $Output & "Lockout: " & $objItem.Lockout & @CRLF
      $Output = $Output & "Name: " & $objItem.Name & @CRLF
      $Output = $Output & "PasswordChangeable: " & $objItem.PasswordChangeable & @CRLF
      $Output = $Output & "PasswordExpires: " & $objItem.PasswordExpires & @CRLF
      $Output = $Output & "PasswordRequired: " & $objItem.PasswordRequired & @CRLF
      $Output = $Output & "SID: " & $objItem.SID & @CRLF
      $Output = $Output & "SIDType: " & $objItem.SIDType & @CRLF
      $Output = $Output & "Status: " & $objItem.Status & @CRLF
      if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop
      $Output=""
   Next
Else
   Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_UserAccount" )
Endif


Func WMIDateStringToDate($dtmDate)

    Return (StringMid($dtmDate, 5, 2) & "/" & _
    StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) _
    & " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate,13, 2))
EndFunc

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...