Jump to content

User/PW: User field gather local accounts as option


JamesT
 Share

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
Link to comment
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)
GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case Else
            ;;;
    EndSwitch
WEnd

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 & "|"
        Next
    EndIf   
    Return StringTrimRight($sTmp, 1)    
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...