Sign in to follow this  
Followers 0
raj2734

Need Help w/ Control List View

4 posts in this topic

I'm trying to write a script to open lusrmgr.msc select the Guest account and change it to something else. I'm a noob to AutoIT. So far i've been able to select the account that I want to change (Guest) and now i'm trying to figure out how to rename it to something else.

CODE
$From = "Guest"

$To= "Guest1"

Opt("WinTitleMatchMode", 4)

Run(@ComSpec & " /c " & 'lusrmgr.msc', "",@SW_HIDE)

WinWait("Local Users and Groups","Local Users and Groups (Local)")

Sleep(2000)

$CLVItem = ControlListView("Local Users and Groups","","SysListView321","FindItem","Users")

ControlListView("Local Users and Groups","Local Users and Groups (Local)","SysListView321","Select",$CLVItem)

Send("{Tab}{Enter}") ;Probally a better way to do this...

$CLVItem = ControlListView("Local Users and Groups","","SysListView321","FindItem",$From)

If($CLVItem =-1) Then

MsgBox(0,"","Entry " & $From & " not found")

Exit

EndIf

;MsgBox(0,"","Entry " & $From & " at "& $CLVItem)

ControlListView("Local Users and Groups","Local Users and Groups (Local)","SysListView321","Select",$CLVItem)

#cs

I've now highlighted the account I want to change but I can't seem to find a way to rename the account.

I either need to single click it and then wait a second and send the text or

right click and go down to rename

#ce

Any help would be greatly appreciated

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

I'm trying to write a script to open lusrmgr.msc select the Guest account and change it to something else. I'm a noob to AutoIT. So far i've been able to select the account that I want to change (Guest) and now i'm trying to figure out how to rename it to something else.

Zedna is right, the _GuiCtrlListView_* functions will help with that, but you would be much better served to drop the GUI entirely and learn to use the WMI COM interface for this. This demo only lists the accounts, but it can do a lot more if you learn how to use that interface:
Global Const $wbemFlagReturnImmediately = 0x10
$strComputer = @ComputerName

$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_UserAccount", "WQL", $wbemFlagReturnImmediately)

$sMsg = "Local User Accounts: " & $strComputer & @CRLF & "____________________" & @CRLF & @CRLF
For $objItem In $colItems
    $sMsg &= "Name: " & $objItem.Name & @CRLF
    $sMsg &= "FullName: " & $objItem.FullName & @CRLF
    $sMsg &= "AccountType: " & $objItem.AccountType & @CRLF
    $sMsg &= "Description: " & $objItem.Description & @CRLF
    $sMsg &= "Status: " & $objItem.Status & @CRLF
    $sMsg &= @CRLF
Next

ConsoleWrite($sMsg)

muttley

Edited by PsaltyDS

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

Share this post


Link to post
Share on other sites

Thank you both for your responses. I came up with a work around to get it to work with the Gui. However I agree that doing this without involving the Gui would be much better so i'm taking you up on your advice and looking into learning how to use the WMI COM interface. Initially I was hoping to do it via the command line but couldn't find anyway to do so went the Gui route. Thanks Again.

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