1

How can I login into a locked windows, using some command in a .BAT file? I can lock the screen easily from my Java program : RunDll32.exe user32.dll,LockWorkStation

Is there any way to login later automatically (from my running Java program), if I know the password?

thatsmyname
  • 45
  • 1
  • 6
  • 1
    wouldn't this be a security hole? – npocmaka Oct 26 '16 at 11:57
  • In short, no. There is no native out of the box way to do it. But there is a long way: to implement a customized [credential provider](https://msdn.microsoft.com/en-US/library/windows/desktop/mt158211(v=vs.85).aspx), but sorry, I don't know if this can or can not be done in java. – MC ND Oct 26 '16 at 12:19
  • Even that `LockWorkStation` idea is wrong; it [doesn't have the right signature](http://stackoverflow.com/a/3207411/15416). It should have 4 arguments, not 0. – MSalters Oct 26 '16 at 12:23

1 Answers1

1

No, doesn't work - by design. The login dialog runs in the secure desktop. That's why you see your screen darken when you switch to that desktop.

The goal of the secure desktop is to protect against the sort of manipulation that you are trying to achieve. IOW, even if there was a bug in Windows that would allow it today, it likely would be patched next week.

MSalters
  • 173,980
  • 10
  • 155
  • 350
  • I use chrome RDP, and it is able to function in the secure desktop. At the very least it is possible to create a program that moves your cursor to the user profile, clicks it, and emulates keyboard input to login. However, this would be a very easily broken solution because what if a new user account is added/deleted? Then, your cursor would click on the wrong user account and it wouldn't log in. – Jack G Feb 06 '18 at 22:26