Remote Desktop Mobile autologin

As you may know, Remote Desktop Mobile (RDM) does not support auto-login. But sometimes you may want a user does not change settings and is directly connected to a Terminal Server. Ruggedized devices are often used in warehouses and the IT structure uses a terminal server to gather data and manage goods. Although I think Windows Mobile is not the right OS for such barcode scanner devices, you may have no choose and have to use a handheld computer with Windows Mobile instead one that uses Windows CE. The RDM or Terminal Service Client provided with Windows CE devices is much more flexible and can be configured by the OEM to enable you to auto-login into a Terminla Server (TS).

OK, the challenge was to automate the startup and login of RDM on a Windows Mobile 6.1 device. I started using embedded Visual C++ 4.0 although this is outdated by VS2005 and VS2008.

The idea was to launch the exe, fill in the values and click the Connect bar.

Finding the connect dialog window

Normally, on desktop windows, windows and there childs are located in there own tree (see desktop PC spy++ screenshot). On WM61 I found, that the RDM window (class=”TSSHELLWND”) and the Connect dialog (class=”Dialog”) are located side by side below the desktop window (see cespy screenshot). This makes it hard to find the right dialog, especially as the Connect Dialog does not have a unique window title (window text). The windows can be identified as belonging together by there processID.

RDM Connect Dialog

Filling the fields

Knowing the right window I was able to set the text entries by knowing there controlIDs (dialogs use ctrlIDs for easier access of the data, see scanTscDialog() in tscDialog.cpp). So the tool I did can fill in all connection details using SetWindowText().

Execute the Connect

The fields are filled with the connection details and now I needed a way to simulate a click onto the connect button (which is a menu in reality) to let the dialog execute a connect. I tried several approaches, the best is to use keyb_event although it works also by sending the TSC window the WM_USER message that is posted by the menu click. I found this WM_USER message within messages of cespy as I tapped on [Connect].

I was unable to send TSSHELLWND nor the Dialog a click onto the menu option [Connect]. The menu seems to be not owned by either of these two visible windows. The menu bar looks like owned by the desktop window.

Sending the SoftKey1 (F1) was also unsuccessfull for window handles of TSSHELLWND and the Connect Dialog.

The pitfalls

Everything seems to work OK, but sometimes the tool was unable to fill the fields and execute the connect. I did search several hours and then I found, that the registry and a file is involved in the connect.

The tool always failed to autoconnect after the first clean boot. So I did a snapshot with the famous free SSNAP by “S-K tools” and found the changes that caused a manualy connect to be successfull.

Registry changes

First, the registry will get be changed, if you manually connect. As I did not like to have my tool to emulate a user typing into the fields using keybd_event, I added code, that does the same changes to the registry (see writeMRU() function in code). There are some more changes in registry, but fortunately I did not have to implement these too (see comments in “tscDialog.cpp”).

RDP file default.rdp

When you fill the connect dialog and then press [Connect] RDM will save your values in a file \Windows\default.rdp. You may know, that rdp files are commonly used on desktop windows to save/load Remote Desktop Session connection data. Yes, WM6.1 does use a similar technique.

The tool had to provide a default.rdp with the data of the connection settings. So I wrote a function to create and write this file from scratch on every start (see writeRDP() in tsc_dialog.cpp and rdp_file.h). As options, like “FullScreen” or “Fit to Screen” are also controlled by the rdp file, I was able to control these settings by code.

Conclusion

So far the tool works. Dont download if you dont like spaghetti. The code is written as grown.

Then simply start the tool. First it will terminate a running instance of RDM. Then it starts a new instance and starts to fill the fields and do the connect.

Warranty

No warranty, code is provided as is. Hopefully it is usefull for the one or other.

Changes

Some values are hard coded, ie the control IDs used. These IDs may be different on other devices or within other RDM releases. So far the code works on my testing device. If you need to change the control IDs you may use the scanTscDialog() function to get the actual codes listed in the debug window.

12 Comments

Hello josef,
I have read your post on intermec forum about the CK3 postamble and vwconfig.ini
I have 10 CN3 without postamble issue and RDM. Now I have 3 new ck3 with that issue. After installing new intermec firmware and cab file to solve that issue, I have now the porblem with the slow character transmission.
I can’t find vwconfig.ini in the windows ck3 directory. I have probably miss something or not understand in your post success story with.
Can you help me?
Tanks
Christophe

Hi Joseph. We use MC9090 handhelds in in our supply chain operations. We use these hand helds to connect to VDI session via RDP mobile. We are finding that alot of users are altering the generic ID on the sign on screen. I was asked to find a way to bypass the sign on screen using pre-defined credentials. Your program is defintly the solution. I have been able to get it to work once or twice. Once, it didn’t reference the registry entry but did “hit” the connect button using the generic ID that was in the fields. I disconnected and reconnected. On this attempt I saw it populate the fields using the data I entered in the registry and connect. I disconnected. Lastly, I ran it again and nothing happened. Your input is welcomed. This is the solution I’ve been looking for. Also, how and where should I be installing this program.

Right now, I’ve dropped the .exe in /application/. As well as the registry file. I clicked on the registry file and it put an RDP_autologin entry in the HKEY_LOCAL_MACHINE.

I’m also trying to use the Remote Desktop Mobile on CK3 and found that the function keys had no action in the remote session. I tried to release some keys using your FuncKeys tool, but it didn’t work. Have you experienced this ? Do you I need to remap F1 to F12 into special values ?

I am sorry but I dont know the MC9090. It sounds like it runs Windows CE and not Windows Mobile. If so, you dont really need the rdp-autologin, as most WinCE devices come with an RDP client featuring autologin (depends on how the OEM compiled RDP in there OS build). Why do I think you are using WinCE? Cause double tapping a reg file in WM will NOT import the registry settings.

I am sorry, but even if you free manage to ‘free’ the function keys, the Remote Desktop Mobile (RDM) app will not forward them to the host. The RDM is a very restricted implementation and lacks many usefull features of the Windows CE Terminal Service Client or the desktop one. As MS stated, RDM is only for occasional use.

here is an update to post: There is a nice RDP client in a separate installer cab. If you dont like the one installed on your device, try this one (called also RDP Finster or Crossbow RDP). Install it to DEVICE nor memory card. The Crossbow RDP also supports some keyboard mapping, see tscscan.txt. The function keys are currently not mapped. According to this site (http://www.quadibloc.com/comp/scan.htm) the HW scan codes for the function keys F1 to F10 are 0x3B to 0x44, the virtual windows key codes for F1 to F10 are 0x70 to 0x79. So function key mapping should look like this:

So I have been able to get the application to work. I have found that it is not terminating the existing wpctsc.exe (RDM) before it starts and is freezing up. If I kill the wpctsc.exe process before I execute the RDP_autoLogin.exe it works fine. The other issue I am having is, it is not retaining my screen size. I want the “fit remote desktop to screen” to stay selected but it will not. As a result, I keep getting that box within a box to scroll the screen when I am connected remotely. This little program is great. I hope I can get it work. Would you want to open an email communication so I could send you screen shots? Thanks for your help!

the code is written to kill an existing RDM beofre it starts a new instance. Cannot actually say, waht is wrong with my kill code. Will have a look later.
I will take also a look at your “fit remote desktop to screen issue”.

There is a registry option to control fit-to-screen. Please try setting this to 1 instead of 0 and see if it fixes your issue. Remember that manually changing options in RDM will be overwritten with settings from RDM AutoLogin code.

Leave a Reply

Donation/Spenden

This site brings you a lot of information and publishing and hosting costs me time and money. If you appreciate my work and would like to support me and enable me to publish some of the apps in Android Play Store and Windows Phone Store then consider making a donation.
Thank You.