To run Windows UI automation, the machine has to be in unlock state. However, the test machine may be located in a data center, a cloud, or a locked lab. Remote desktop is the best way to acces it. What will happen when remote desktop is disconnected? Windows’s local console is locked. If UI automation is kicked off, it may not run as expected.
The solution is to use Task Scheduler. Create a new task with elevated privileges.
The trigger of the task is when a user disconnects a remote session.
The action to be taken is to run the command “tscon 1 /dest:console“, where 1 is the user ID. To find the user ID, go to Users tab in Task Manager.