cancel
Showing results for 
Search instead for 
Did you mean: 

Login Agent incorrectly shows machine is not locked

NicholasZejdlik
Level 9
Is there any reason why Blue Prism would be incorrectly determining the lock state of a machine? I'm running v6.10 on a Windows 10 VM, and it's not always detecting if the machine is locked or not. It does correctly determine if it is logged in or not, but the "Is Locked" in the Login Agent object keeps coming back as false when it is in fact locked. I'm using TeamViewer to connect to the VM. RDP is not in use, and "query user" in command prompt shows I am on the Console session.

The problem with it not correctly determining the lock state is that, in order to unlock, I need to send an SAS. But if I send an SAS and it's not actually on the lock screen, it brings up the Ctrl+Alt+Del screen which I cannot seem to programmatically close.

If I run this on my own computer (also Windows 10) - which does not have any of the group policies set - it does correctly determine that my computer is locked.

Is there something I'm missing that would cause Blue Prism to think the VM is not locked when it is in fact locked?

------------------------------
Nicholas Zejdlik
RPA Developer
------------------------------
1 BEST ANSWER

Best Answers

NicholasZejdlik
Level 9
After doing some digging, I found that OpenInputDesktop, which is the function that the Login Agent code uses to determine if the screen is locked or not, was coming back that there is active desktop while Windows was sitting on the lock screen. I also noted that a screenshot taken via Graphics.CopyFromScreen likewise returned successfully while on the lock screen (as opposed to throwing an invalid handle exception, which is usually what happens). The desktop would go inactive briefly while locking and also while typing the password in to unlock, but would remain active while the lock screen was up and no input was being made.

The issue seems to be related to the version of Windows. Unbeknownst to me, this particular VM had Windows 10 Pro installed instead of Enterprise. It seems that in Enterprise, the desktop is inactive when the screen is locked, whereas on Pro, the desktop is still active even on the lock screen (perhaps this is due to a configuration somewhere).

What ultimately resolved this was changing the code that the Login Agent object uses to determine if the screen is locked. I came across a StackOverflow post with exactly the issue I was running into that pointed me in the right direction. I replaced the Is Locked code in the Login Agent object to check if the logonui process is running instead of using OpenInputDesktop: Locked = System.Diagnostics.Process.GetProcessesByName("logonui").Length > 0.

This seems to be working like a charm so far. It seems the only "official" way to determine if the lock screen is active or not would be to create a service and subscribe to the SystemEvents.SessionSwitch events. As far as I can tell, there is no Windows function to determine directly if the screen is locked or not, which seems unfortunate. Anyway, I hope this helps if someone gets caught in a similar situation.

------------------------------
Nicholas Zejdlik
RPA Developer
------------------------------

View answer in original post

4 REPLIES 4

NicholasZejdlik
Level 9
After doing some digging, I found that OpenInputDesktop, which is the function that the Login Agent code uses to determine if the screen is locked or not, was coming back that there is active desktop while Windows was sitting on the lock screen. I also noted that a screenshot taken via Graphics.CopyFromScreen likewise returned successfully while on the lock screen (as opposed to throwing an invalid handle exception, which is usually what happens). The desktop would go inactive briefly while locking and also while typing the password in to unlock, but would remain active while the lock screen was up and no input was being made.

The issue seems to be related to the version of Windows. Unbeknownst to me, this particular VM had Windows 10 Pro installed instead of Enterprise. It seems that in Enterprise, the desktop is inactive when the screen is locked, whereas on Pro, the desktop is still active even on the lock screen (perhaps this is due to a configuration somewhere).

What ultimately resolved this was changing the code that the Login Agent object uses to determine if the screen is locked. I came across a StackOverflow post with exactly the issue I was running into that pointed me in the right direction. I replaced the Is Locked code in the Login Agent object to check if the logonui process is running instead of using OpenInputDesktop: Locked = System.Diagnostics.Process.GetProcessesByName("logonui").Length > 0.

This seems to be working like a charm so far. It seems the only "official" way to determine if the lock screen is active or not would be to create a service and subscribe to the SystemEvents.SessionSwitch events. As far as I can tell, there is no Windows function to determine directly if the screen is locked or not, which seems unfortunate. Anyway, I hope this helps if someone gets caught in a similar situation.

------------------------------
Nicholas Zejdlik
RPA Developer
------------------------------

Hi Nicolás!

Thanks for sharing the problem and the solution with the community so the problem originates from the difference in the session locked of the window 10 Pro and Enterprise versions and is fixed by setting a line of code in the Login Object.

best regards

------------------------------
Jhogel Ponne
Senior RPA
Ernst & Young
America/Panama
------------------------------

Hi
My PRD environment is parameterized correctly to unlock the screen, but occasionally it gives a false positive when unlocking I tried to test the solution proposed by you but I have the error below, can you help me?

12956.png

</c-wiz>

------------------------------
Daniel Marques
------------------------------

Something that I neglected to add on my earlier post, one side effect of that change is that it will report the screen is locked when it is in fact not logged in. With the original login agent, it would report Is Locked as false when Is Logged In is false, whereas with the change it will report Is Locked as true when Is Logged In is false. If you are using some logic to determine if an unlock or a log in is needed, it is possible that might need a revisit with the change.

If that is not the issue, I would check out this article and see if that helps any. Like the article suggests, perhaps the robot is stuck on a Ctrl+Alt+Del prompt (can use SAS to get around that), or is being accessed via RDP?

------------------------------
Nicholas Zejdlik
RPA Developer
------------------------------