Jump to content
Sign in to follow this  

User/PW: User field gather local accounts as option

Recommended Posts


I have created a program that requires a user/pw. Currently, a user types in the information.

What I need is the user field to provide a list box with local accounts. For example: Right Click IE and Runas. When the RunAs window opens, you can either type in account information or choose a local administrator account and type in the pw.

How do I pull the info from the system. I've tried writing several scripts utilizing WMI; however, I simply failed. Examples would be great!

On a second note. I need the same thing; however, it also needs to display smartcard information. **See runas example above** I could then choose the smartcard for authorization.

The first request is a must the second is a plus!!!

Edited by JamesT

Share this post

Link to post
Share on other sites

Hi, for the list of user accounts in XP I use something like this

#include <GUIConstantsEx.au3>
#include <ComboConstants.au3>

$hGui = GUICreate("User Accounts", 200 , 30)
$Combo = GUICtrlCreateCombo("", 5, 5, 190, 20, $CBS_DROPDOWNLIST)
$sLUA = _ListUserAccounts()
$Default = StringLeft($sLUA, StringInStr($sLUA, "|", 0, 1)-1)
GUICtrlSetData(-1,$sLUA, $Default)

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
        Case Else

Func _ListUserAccounts()
    Local $colUsers, $sTmp, $Array[1] = ["user"]
    $colUsers = ObjGet("WinNT://" & @ComputerName)
    If IsObj($colUsers) Then
        $colUsers.Filter = $Array
        For $objUser In $colUsers
            $sTmp &= $objUser.Name & "|"
    Return StringTrimRight($sTmp, 1)    

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