WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Sending Keystrokes

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Virtual Machine and SendKey

 Keywords: Virtual Machine VM VMWare Remote Desktop Send Keystroke SendKey SendKeysTo Mouse MouseMove Mouse Click Locked Console Disconnected RDP Session

Question:

I am having a problem with Winbatch running in a Virtual Machine. Virtual Machine software is VMWare ESXi 5.0.1 It doesn't type in keystrokes when it should. When I am connected to the virtual machine (via RDP for example), everything works fine. When I run the script (with a timer) and I'm not connected to the machine, the script runs but does not enter the keystrokes.

The strang thing is that I have another client where we are running Winbatch similarly disconnected and Winbatch does respond to SendKey(). The obvious question is what is different between the two clients.

Answer:

If a session is truly disconnected, it will not be able to receive user input. The problem is that the SendKey*() and Mouse related functions do not work on a locked console or in a disconnected RDP session. The script will need to be rewritten to work in a different manner, possibly using the Control Manager extender or COM/OLE to get around this limitation.

However, you can shadow (remote attach) to an existing console session and then detach from it. When you do this, the console session's Default desktop processes will still receive user input after the detach until the session switches to a different desktop like the screen saver/Winlogon desktop or is shutdown by logging off. The physical system console session can remain in an unlocked state, and while unlocked, the SendKey*() and Mouse*() functions will work properly. This might explain why it works for one client and not another.

There is absolutely no ambiguity involved with how these functions behave w/respect to unlocked sessions and locked/disconnected sessions. The only variable involved is what state the session is actually in at any given time, which may not be obvious and is implied by how these functions are behaving at any given time. If the script will be running in a session that has any possibility of going into a locked or disconnected state, then the script needs to be rewritten to not use the SendKey*(), Mouse*() or any other functions that do not function in a locked/disconnected session. Again, the script will need to be rewritten to work in a different manner, possibly using the Control Manager extender or COM/OLE.


Article ID:   W18275
Filename:   Virtual Machine and SendKey.txt
File Created: 2013:06:27:08:47:30
Last Updated: 2013:06:27:08:47:30