Restoring keyboard settings after a remote desktop session - Windows 7

3

1

We have USB scanners that require Num Lock key to be ON to work properly. I noticed when I remote logged in to a PC (remote desktop) and my num lock key was OFF then the remote PC will also turn it off after the session is terminated. How can I prevent this? I would hope that the keyboard settings could be restored after the RD session is terminated.

Mark

Posted 2014-08-21T20:24:16.150

Reputation: 31

Answers

0

You have to define that a certain task has to be executed on the remote PC when you terminate the Remote Desktop session. I prefer to run a simple batch file on the remote computer under certain conditions (see below). This batch file uses the command line tool 'klocks.exe':

klocks.exe -scroll +num -c

This line just activates the NUMLOCK state (and deactivates the SCROLL and the CAPSLOCK state). Unfortunately I noticed that the original download site is not available anymore (http://www.commandline.co.uk/klocks/index.html), but perhaps you find it somewhere else. As an alternative commandline tool you could use the tool numlock.exe (http://www.rjlsoftware.com/software/utility/numlock/) but I am sure there exists other commandline tools like this. A third possibility may be to use a small VBS script to set the NUMLOCK state, but I have not tried it yet (see faq-o-matic.net):

set WshShell = CreateObject("WScript.Shell") WshShell.SendKeys "{NUMLOCK}"

Whichever script you choose, it shall be executed when you 'terminate' the RDP session. There are two possibilities to terminate a RDP session:

  1. disconnect from the remote user session by just closing the remote desktop window
  2. terminate the remote user session by logging off

For a simple 'disconnect from the remote user session' you should use the Windows task scheduler on the remote PC. Just define the trigger "disconnect from user session" and define as an action the 'NUMLOCK-on' script.

For 'logging off' from the remote user session, i. e. a real termination of the session, it's not easy to use the task scheduler because there exists no predefined trigger for 'logoff'. Instead you should use the local group policy editor to define a logoff script (in user configuration > Windows settings > Scripts > logoff).

BTW To be sure that NUMLOCK will always be activated on the remote computer when a remote user is logging on (i. e. not just entering an existing session) there are several possibilities:

  • use the local group policy editor to define a logon script
  • use the task scheduler to define a task with trigger 'logon'
  • set the registry value InitialKeyboardIndicators to 2 (HKCU\Control Panel\Keyboard, see https://technet.microsoft.com/en-us/library/cc978657.aspx)
  • use the different autorun possibilities in the registry

Thorsten Albrecht

Posted 2014-08-21T20:24:16.150

Reputation: 124

0

This was mentioned (though hidden) in a previous answer, so I'm gonna highlight it for anyone else that ends up here, as I didn't find it until I went and did a bunch of searching myself:

  1. Open the Registry Editor.
  2. Navigate to HKEY_USERS.Default\Control Panel\Keyboard
  3. Change the value for InitialKeyboardIndicators to 2.

Roderick

Posted 2014-08-21T20:24:16.150

Reputation: 181