Ask a Question

Unable to run test - User session locked

Occasional Contributor

Unable to run test - User session locked



I have a scheduled task that run a TestComplete project - containing GUI tests and file checkpoints.

I have the following error in the testcomplete log (when running putty to connect to Unix machine):


The operation cannot be performed , because the user session is locked

Possible reasons:
* The computer is locked.
* The UAC prompt is displayed asking for a user confirmation, and the user session is locked until a response is provided.


The test (and the scheduled task) is run on a distant machine (Virtual Machine), that we access to via a remote desktop.

The machine OS is Windows 2012 Server - R2


The option 'Run only when user is logged on' is checked in the task properties

'Run with highest privileges' is also checked.

'Start the task only if the computer is on AC power' is checked

'Wake the computer to run this task' is checked


Before running the task, I disconnected the user via tscon utility as mentioned in this page


The screen saver is disabled.


In the power options, 'Turn off the display' is set to Never

'Put the computer to sleep' is set to Never


Could you please help me to solve this issue, so that the test could be planned via task scheduler ?



Esteemed Contributor

Your remote machine... is it a VM with an available console screen?  The reason being is that, if it's a regular PC you're logging into, the TSCON process MIGHT not work.  If you can, verify that after the TSCON is run, that there is, somewhere, a console of the PC running unlocked with a visible UI.

Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
Occasional Contributor



Yes, my remote machine is a virtual machine.

So, is there any solution if tscon does not work ?





a) Are you sure that disconnected session is not locked after some timeout? (I am not 100% sure, but note, that while switching to console with tscon, if console session already exists (or created?), it is possible that it will be running under different user and thus your display settings may not match those for the console.);

b) tscon requires administrative permissions and must be executed 'As Administrator'.


Can you check that both conditions are met?


As a last resort you may try a bit tricky workaround:

-- Open remote session to same machine (boxA);

-- Open remote session to your test machine (boxB) from boxA. I.e. you will get remote session running within another remote session;

-- Launch tests on boxB;

-- Disconnect boxA remote session. Session disconnection should leave remote session on boxB running.

  /Alex [Community Hero]
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
Showing results for 
Search instead for 
Did you mean: