Sorry, maybe it's a bit late here but I still can't understand the root of the problem. I thought that you were having problems with locked machines when you log off from Remote Desktop session - because I've faced them and I spent some time trying to find appropriate solutions.
But in your case - machine A (master) and machine B(slave) are locked starting from 5 p.m. If machine A has scheduled task for midnight - what can prevent it from starting the tests on machine B? It's not the problem that machine B will be locked locked - because TestComlete/TestExecute can successfully login if you specify appropriate credentials in the settings of you Network task. It's also not the problem, that machine A will be locked - there is not UI needed for A to run tests on B and gather results.
So, everything that you need to do - organize the right communication between A and B. Just invoke Slave task run from in the script, that is executed on Master and that's it.