17

I would like to write a small application that unlocks the workstation. To put the specs of what I need very simple: Have an exe that runs and at a defined time (let's say midnight) unlocks the workstation. Of course the application knows the user and password of the logged on account.

I know of the LogonUser API and have tried using it but failed. Does anyone have a solution, code excerpt that actually works for this issue?

I am targeting NT5 OSes.


Well, since people started asking what is the reason: I am working on a desktop sharing application and I want to add the feature of unlocking the workstation. Having the very small and simple app to unlock the station at a defined time is in order to separate the problem and to avoid the integration details.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Dan Cristoloveanu
  • 1,974
  • 1
  • 13
  • 20
  • Why? Are you sure there is no better way of doing what you are trying to do? – Coincoin Oct 06 '08 at 13:15
  • 1
    That sounds like a very bad idea. What is the purpose of this? There's probably a better solution... –  Oct 06 '08 at 13:16
  • 1
    I am pretty sure this is a bad idea and (I really hope) impossible as well. – GEOCHET Oct 06 '08 at 13:18
  • Look into overriding GINA, but as the other two say, it's a pretty bad idea. Why would you want to do this, you can just have a service running on the computer to do anything you want on it anyway. – Henry B Oct 06 '08 at 13:19
  • 1
    Can you please trigger any advice that worked for you? I deal with the same problem and I found this article (http://waynes-world-it.blogspot.com/2008/04/unlocking-xp2003-without-passwords.html) interesting. However, it does not work for me, as target application (Rational Functional Tester) which is supposed to be run periodically in interactive mode checks that desktop is actually (not fakely) unlocked. – dma_k Jul 13 '10 at 14:59
  • For all of you up here noting that it's bad and impossible. We are building a remote testing platform, and we need to remotely control many computers parallel. Locked computers are bad, since we control the mouse the keyboard, and capture the screen to handle the programs. Is this pure evil? Get to your senses already... – Kobor42 Apr 10 '14 at 08:27
  • There are more implementations possible for authenticating a user via Windows using C#, can people not just answer the OP's question without passing judgement on what they're trying to achieve? – ataraxia Jul 26 '19 at 11:58

4 Answers4

9

Just so you have an answer for this instead of people leaving answers which might be better off as comments.

This is certainly possible, though as many people have already said it's not really wise, what happens if someone is walking by the computer as it unlocks, how long do they have to play around, etc?

Anway, apart from suggesting you have a service to do any work that you want on hte computer, or even remotely connecting to the computer to do work you might be able to make user of the following information. (as for 'code excerts' you can make it yourself)

http://www.paralint.com/projects/aucun/ is a GINA implementation which will be able to give you rights to log on even if someone else has already logged on. Look into it it might be what you're looking for and is a lot safer than unlocking the workstation at a certain time.

As an alternative, look into writing your own GINA implementation that will do an unlock at a scheduled time.

Information on GINA

http://msdn.microsoft.com/en-gb/magazine/cc163803.aspx

http://msdn.microsoft.com/en-us/magazine/cc163786.aspx

After you've unlocked the desktop I'm pretty sure you're going to want to lock it again.

http://www.codeproject.com/win32/AntonioWinLock.asp

Platinum Azure
  • 45,269
  • 12
  • 110
  • 134
Henry B
  • 7,947
  • 10
  • 42
  • 46
  • @finnw: I agree about the language. I edited it to make it occupation-neutral, hope that's okay with the OP. You should be able to remove your -1 though. – Platinum Azure Oct 28 '11 at 20:00
  • 1
    Another consideration : GINA is regarded as obsolete. See http://msdn.microsoft.com/en-us/magazine/cc163489.aspx – Henry Aloni Sep 09 '13 at 09:12
2

Just to add another lead (an not have any judgment), autoit (a scripting Windows language) may have an answer, as described in this thread:

How to unlock an Xp desktop

And I just found another scenario where one might want to unlock a desktop ;)

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

Let your app run as a service, then you do not need user/password as that is set up with the service.

Johan Bresler
  • 6,450
  • 11
  • 56
  • 77
0

For my situation I needed to be able to restore the console session after I've disconnected my terminal session (I'm connecting to a WinXPe kiosk with a touchscreen, but no keyboard).

Here's a command line solution I found to work. Instead of closing my session window to disconnect, I run a batch file with the following line. My session is closed and the console session is restored unlocked.

  • automatically unlock workstation after terminal session on WinXP

    tscon.exe 0 /dest:console
    
  • for Windows Vista/7 the console session number has changed from 0 to 1, so you need to use

    tscon.exe 1 /dest:console
    



Source link: http://arstechnica.com/civis/viewtopic.php?f=15&t=69113

zomf
  • 1,289
  • 1
  • 14
  • 13