0

I've seen this question but I have a specific requirement: I need to have a windows server machine start the user session after a restart without unlocking the user screen.

The reason for that is that I need a lot of stuff to run automatically on a machine that requires a user session and this machine needs to restart every day. I use a VMWare cloud provider for this machine. If I were to use autologon, the provider would have access to this machine's desktop without being prompted a password, this doesn't happen If I connect via SSH or RDP (the provider gets asked for a password). I believe that if I were able to start a user without logging the user, that would solve this problem.

Mefitico
  • 143

1 Answers1

1

One idea would be to have a scheduled task running repeatedly that:

  • Checks if no SSH session is running and locks the screen
  • Detect that SSH is running and unlock the screen.

For detecting an SSH session, see the post Powershell alternative to Unix who command to show ssh sessions.

The task could be written using PowerShell. The following command from this post will detect an SSH session:

Get-CimInstance -ClassName Win32_Process -Filter "Name = 'sshd.exe'" | Get-CimAssociatedInstance -Association Win32_SessionProcess | Get-CimAssociatedInstance -Association Win32_LoggedOnUser | Where-Object {$_.Name -ne 'SYSTEM'}

For locking the screen you could use nircmd with the command nircmd.exe monitor off, or Display Power Off Utility with doff.exe /l.

The scheduled task could be set to run every minute, as it's not very resource-demanding. A similar test could be done for an RDP session.

harrymc
  • 498,455