I\'m attempting to automate Coded UI tests.
My test controller launches the tests on a remote test server, which I normally access via a Remote Desktop connection.
The easiest solution to this problem was simply to enable auto-logon on my test environment (there are a variety of ways of doing this depending on OS).
With auto-logon enabled, when I restart the test environment (using the 'shutdown.exe /r' command, which can be scripted), the test environment loads back up with an active, logged on session, and so the tests can run successfully.
For my nightly test automation, I enabled auto-logon on my test environment and scheduled a restart prior to test execution.
I have had no issues with this method - and it means I don't have to connect via Remote Desktop.