How to unlock Windows lockscreen?
Asked Answered
D

5

11

How can I unlock the windows lockscreen with Delphi? I didn't found anything on Google or Stackoverflow. I already tried to enter my password using keybd_event but it seems like the events dont work on the lockscreen.

Dobruja answered 11/4, 2013 at 17:58 Comment(4)
You mean the screen which requires CTRL+ALT+DEL? Because that's deliberately designed to be impossible to unlock it from any application other than Windows its self.Alsatian
Make your program send an e-mail to a user: "Hey! Please unlock the computer."Callen
I think this can be done from kernel mode, though I don't have precise instructions, how to do this. Also to get anything into kernel mode you need to have direct permission from administrator (in order to install a kernel-mode driver).Botch
I think this is doable. but I just can't figure out why?Nahum
E
9

You cannot unlock the lock screen programmatically from user space. That is by design.


OK, let's clarify that. Using documented APIs, you cannot do this. You need to reverse engineer undocumented APIs as @Remko has done for his SasLibEx product.

Ecstasy answered 11/4, 2013 at 18:8 Comment(9)
Agreed. It would be a HUGE security risk if arbitrary apps could unlock the PC at will.Proa
This is actually the purpose of the lock screen, to lock your computer up.Alsatian
I'm thinking "terminal services client"... maybe I'm off, but it seems that there is an automation way to unlock the user account with "auto" log-on.Nahum
@Nahum The system does auto logon. It can do anything it pleases.Ecstasy
I mean that terminal services client can send username/password and login into a remote account. I really think it's doable and that the client can unlock the account programmatically. I don't see any reason why it cant be done.Nahum
@Nahum Terminal services is part of the system, so it can do what it wantsEcstasy
If it can do whatever it wants so can we.Nahum
@Nahum I think in newer RDP versions authentication is negothiated before the real RDP session is created. Credentials are not sent via RDP channel?Squamulose
@Nahum Hardly. The system can do more.Ecstasy
H
8

Remko Weijnen has very interesting projects in this direction. He has released a command-line tool (Winstation Locker) which is capable to unlock local/remote Windows XP station, without knowing the password of the user who has locked the computer.

For Windows Vista and later he has developed SasLibEx** library which can unlock even specific terminal services sessions, again without username/password.

Both methods require you to have Administrative privileges/account at the destination computer.

PLEASE NOTE, all these tools use nasty hacks that may be considered illegal, inappropriate, intolerant or criminal(?). It should be discussed with your Clients/Employer and should be used with caution!

** SasLibEx is a commercial product

Heinz answered 11/4, 2013 at 21:18 Comment(10)
Thanks for linking to my tools! But please note that the Winstation Locker is free but that SasLibEx is a commercial solution.Preconize
@DavidHeffernan the link to the Winstation Locker describes exactly how it works... As for SasLibEx it's not public, but the enterprise version comes with source!Preconize
@Preconize So how does it work? On the face of it, it sounds like a library that could be used to build malware.Ecstasy
@DavidHeffernan the library is aimed at remote control and virtualization software. Some examples: simulate ctrl-alt-del press, (un)lock is very useful for classrooms, teacher can centrally lock/unlock screens.Preconize
@Preconize I can see that it would have good uses also. How does it work? Or won't you say? I suspect that unlocking can't be done by fair means and requires reverse engineering and cracking.Ecstasy
let us continue this discussion in chatPreconize
Im using Windows 8 and this is only for me so I dont want to purchase SasLibEx for this.Dobruja
@Dobruja Do you want a standard user to be able to do this, or are you prepared for it to require admin?Ecstasy
@DavidHeffernan it would be absolutely ok if it would require admin. I am the only user who will use this - this is only for me.Dobruja
You'll have to reverse engineer a solution thenEcstasy
Y
7

Steamlink (a piece of hardware that allows you to stream your steam games to a big screen) currently has an issue, that if your screen is in a different part of the house, in order to play you need to walk to your PC unlock it and then walk back to your big screen.

In order to make it less painful, people in the community came up with this script:

@powershell -NoProfile -ExecutionPolicy unrestricted -Command "$sessionid=((quser $env:USERNAME | select -Skip 1) -split '\s+')[2]; tscon $sessionid /dest:console" 2> UnlockErrors.log

It can unlock your PC remotely. You can call tscon.exe from Delphi to emulate the same.

Yoohoo answered 29/12, 2015 at 1:5 Comment(0)
B
3

This actually can be done using powershell, psexec and windows onscreen keyboard. While a program cannot send input to winlogon, the windows osk can, and sure enough a program can send input to osk.

Bovine answered 22/8, 2014 at 5:3 Comment(1)
I accept your answer as solution if you provide a example.Dobruja
P
1

NOTE: The following is a remote solution.

As far as i know, Keyboard events wont work on lock screen unless you switch from Default Desktop to Winlogon desktop(Desktop referring to a container of all activities)

[Background]

Default desktop is the one you use when reading this post. Winlogon would be the one that is set as active when you press Ctrl+Alt+Del

[XP]

You would need to Switch from Default to WinLogon Desktop[Check reference] and then you would be able to unlock machine by getting Window handle for Unlock Computer

IntPtr windowHandle = (IntPtr)FindWindow(null, "Unlock Computer");//Getting Window handle

Send username and password to respective edit boxes.

Reference http://www.codeproject.com/Articles/16197/Remotely-Unlock-a-Windows-Workstation

[Win7] Run tsdiscon.exe from remote. Not sure how this works; but for me, it unlocks the Locked Screen.

Paresthesia answered 10/10, 2014 at 19:12 Comment(1)
Also you would need to add the reg key for tsdiscon.exe to work Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon] "DefaultDomainName"="domainNAme" "DefaultUserName"="domainName\\userName" "AutoAdminLogon"="1" "DefaultPassword"="password"Paresthesia

© 2022 - 2024 — McMap. All rights reserved.