I have a VM that I wish to run an automated task on (i.e. the automated task runs on the actual VM).
The VM is a Windows 2008 server.
I have added the task
OK,
So think i figured it out...
The problem is that once you log out with remote desktop, then the server is locked and no scripts can run. I have tried various options, including ControlSend and ControlClick commands, but without any success.
The solution is as follows: Create a batch file with the following commands and save it to the desktop of the workstation you want to keep unlocked: I have named my file Logoff.bat
START C:\Windows\System32\tscon.exe 0 /dest:console
START C:\Windows\System32\tscon.exe 1 /dest:console
START C:\Windows\System32\tscon.exe 2 /dest:console
START C:\Windows\System32\tscon.exe 2 /dest:console
START C:\Windows\System32\tscon.exe 3 /dest:console
START C:\Windows\System32\tscon.exe 4 /dest:console
START C:\Windows\System32\tscon.exe 5 /dest:console
Tscon.exe comes standard with your windows installation and is specifically created to leave a Previously-Locked Console Unlocked. See this link: http://support.microsoft.com/kb/302801
The next time you log in to the workstation with remote desktop, do not log out the normal way, but run you batch file - in my case "Logoff.bat" This will terminate your Remote Desktop connection and log you out, but will then continue in an unlocked state for any scripts to run as if someone is actually logged in.