Jump to content

Control Userpassword2


Recommended Posts

I'm trying to set auto logon using the userpasswords2 control because it is a bit more secure than plain text passwords in the registry.

I tried a few approaches but none of them work. here is what I have that goes the farthest:

$User = "TestUser"
$Pass = "Password1"
Run(@ComSpec & " /c " & 'control userpasswords2', "", @SW_HIDE)
WinWaitActive ("User Accounts", "Users must &enter a user name and password to use this computer.")
Send("!e" & "!a")
WinWaitActive ("Automatically Log On")
Send("!u" & $user & "!p" & $pass & "!c" & $pass & "{ENTER}")
WinWaitActive ("User Accounts")
Send("{ENTER}")

Everything works fine right up until it gets to the "ENTER" part of the Send("!u" & $user & "!p" & $pass & "!c" & $pass & "{ENTER}") line. Windows gives one of those "you did something wrong" noises and the window stays open. I can manually hit the enter key and it proceeds as normal but the scripting of it does not work.

This one goes almost as far as the previous one:

$User = "TestUser"
$Pass = "Password1"
Run("control userpasswords2")
WinWaitActive("User Accounts")
Send("{space}{ENTER}")
WinWaitActive("Automatically Log On")
Send("+{TAB}" & $User & "{TAB}" & $pass & "{TAB}" & $pass & "{ENTER}")
WinWaitActive ("User Accounts")
Send("{ENTER}")

It one works right up until it is supposed to tab to the second password and then it tabs to a different window like alt-tab.

The final one I tried does nothing after running the control. I'm not even certain if I am using the commands correctly.

$User = "TestUser"
$pass = "Password1"
Run("control userpasswords2")
WinWaitActive("User Accounts")
ControlClick("User Accounts","","[CLASS:Button; INSTANCE:1]")
ControlClick("User Accounts","","[CLASS:Button; INSTANCE:9]")
WinWaitActive("Automatically Log On")
ControlSetText("Automatically Log On","","[CLASS:Edit; INSTANCE:1]",$User)
ControlSetText("Automatically Log On","","[CLASS:Edit; INSTANCE:2]",$pass)
ControlSetText("Automatically Log On","","[CLASS:Edit; INSTANCE:3]",$pass)
ControlClick("Automatically Log On","","[CLASS:Button; INSTANCE:1]")
WinWaitActive("User Accounts")
ControlClick("User Accounts","","[CLASS:Button; INSTANCE:7]")

So I have three options, all of which look like they should work (to me anyway) but none of which work. Is there something stupid I am missing?

Link to comment
Share on other sites

All the commands in the third script have return values and error codes.

Check those to find out which commands are failing.

added variables to each command to log errors and msgboxes to report them but there are no errors. It loads up the User Accounts windows and sits there. If I click on the next two steps manually (ControlClick("User Accounts","","[CLASS:Button; INSTANCE:1]") & ControlClick("User Accounts","","[CLASS:Button; INSTANCE:9]")), it finishes the rest without a problem but it seems WinWaitActive("User Accounts") never realizes it is active so it hangs there.

Interestingly, this is a snip from a much larger script and it works alone but not within the original script.

Link to comment
Share on other sites

  • Moderators

Emolas,

Did it occur to you that these login dialogs are set up to resist automation (for perfectly understandable reasons)? :huh:

In my opinion this falls foul of the prohibition on login scripts and so will be locked forthwith. Please read the Forum Rules before posting again. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...