Windows – Unlock PC with Windows Task Scheduler

automatic-logonlockscheduled-tasksscriptwindows

I need to set up a Scheduled Task to unlock Windows 7 PC at specific time. And second Task, to lock at other specific time. Is this possible by cmd.exe command, or I need to use some third party software? By unlock I meen unlock logon screen.

What I'm trying to achieve with this process:

I have PC, where is running instance of TeamViewer. TeamViewer works only when user is logged on and screen is not blocked. I want to set up at specific time PC screen unlock, so I can remote login into this PC with TeamViewer app. I don't want to setup VPN, I don't want to open ports and allow RDP or VNC, only way I want to connect to this PC is TeamViewer app. I am trying to find out how to setup PC screen unlock with Windows Task Scheduler.

UPDATE:

  • Thanks to user2196728 comment I know how to lock screen(rundll32.exe user32.dll, LockWorkStation from cmd), but still I don't know the most important thing for me – how to unlock it in the first place.
  • There is utility Logon.exe to unlock Windows PC, but I couldn't get it to work on Windows 7, I don't know, maybe it's not working on Windows 7.
  • I understand that for unlock will be required to store user password. In this case, I suppose there is possibility to use plain text. It can look a bit terrifying, but I don't store any sensitive data on this machine. First let's see what can be done, and then, what is best secure way/options to encrypt password.

Best Answer

Check the Teamviewer options... Security > Windows Login. Mine is set for Administrators Only (I run from an administrator account), but you can also select all users.

The resultant behavior is that I can connect to my machine regardless of whether it is sitting at the initial login screen, at the desktop, or at the lock screen. I can then log in/unlock interactively just like I'm sitting at my desk.