0

I would like to implement a way for a windows application or service to lock and unlock the interactive users session based on external input.

Example: when the users phone gets out of range, their session is automatically locked. When the phone gets back in range, the session is automatically unlocked. The IPhone/Mac app "Near Lock" does this.

How can I programatically lock and unlock a user's session, either from an application running in that session or from a windows service?

nvoigt
  • 75,013
  • 26
  • 93
  • 142
user3867261
  • 109
  • 1
  • 2
  • 7
  • 1
    Why would the user want that? It sounds like a security breach and will hopefully be prevented from the system, as long as the credentials aren't given again manually by the user. – Frederic Klein Apr 18 '16 at 07:25
  • Windows supports auto login on reboot through a [registry key](https://support.microsoft.com/en-us/kb/324737). I think the best you can do is set this key programmatically. The problem is that logging off kills all user processes and deletes the session. The only thing that survives this is system services, which run in the system session. The system session has no desktop. No desktop, no login. The only process that can run on the console desktop without a user logged in is the login process. – Ryan Bemrose Apr 18 '16 at 07:31
  • A very dirty way would be to find windows that belong to LogonUI.exe, then send a message to the correct window containing a CTRL+ALT+DEL (this could be painful to achieve), then locate the textbox window that wants the password and write there the password (sending messages) and then send an ENTER – Matteo Umili Apr 18 '16 at 07:39
  • 2
    That sounds like an XY-Problem. What is the real problem your program is trying to solve? – nvoigt Apr 18 '16 at 08:09
  • @nvoigt Hello. My goal is to implement windows version 'near-lock(mac app)'. So I want implement back-ground auto login function. After that I w'll implement BLE modules – user3867261 Apr 18 '16 at 08:18
  • @F.Klein Programmatic Login is supported in the 'near-lock'. It's mac and iphone app. So I wanted to implement that function in the windows and android phone using C# and BLE. – user3867261 Apr 18 '16 at 08:19
  • @RyanBemrose So, There'e way to do that in the service? If i can, I think the way is generating a service when user click the button. – user3867261 Apr 18 '16 at 08:22
  • Even if it worked... what is your service to do, if another user is logged in at the time? How does the service know it's 10 minutes from now? And (sorry, I don't know the mac app) what would that be useful for? I would never run a program that logs me in 10 minutes from now. If I want this done, I will do it myself. – nvoigt Apr 18 '16 at 08:24
  • in summary, near-lock app lock(log off) the system when user's iphone go far from the desktop (detecting with BLE RSSI distance). and when user's iphone come close, near-lock app unlock the system with user's account. So I think i have to use c# service model. the goal of this project is to implement this app in windows version. but before the beginning, I have to learn about C# and Windows API. This is why I want to implement that functions. – user3867261 Apr 18 '16 at 08:29
  • @nvoigt the time is not important, only that i want is the functions that log in to the windows programmatically in background. Now, we can assume that only one user use the system with just one account. – user3867261 Apr 18 '16 at 08:31
  • If you're wanting to interact with the login process, you might be looking to create a [credential provider](https://msdn.microsoft.com/en-us/library/windows/desktop/mt158211(v=vs.85).aspx). It's all quite deep voodoo though, and I doubt you'd be implementing it in C#. – Damien_The_Unbeliever Apr 18 '16 at 08:43
  • So you want to lock and unlock an existing session? – nvoigt Apr 18 '16 at 08:56
  • @nvoigt yes, that i want – user3867261 Apr 18 '16 at 10:12
  • @user3867261 I have made same very radical edits to your question because your wording was very misleading. Feel free to revert it or find a better description if you are not happy with it. – nvoigt Apr 18 '16 at 10:21

0 Answers0