Automated Login for Remote Desktop Mobile

Print This Post Print This Post

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].

 //Solution three, best solution, ensure you use the scancode value too! AFAIK the scancode for F1 is always 0x70
keybd_event(VK_F1, 0x70, 0, 0);
 Sleep(30);
 keybd_event(VK_F1, 0x70, KEYEVENTF_KEYUP, 0);

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.

Usage

Write the correct values for the connection to the registry

[HKEY_LOCAL_MACHINE\Software\RDP_autologin]
"FitToScreen"="1"
"FullScreen"="1"
"Status"="connecting..."
"Save Password"="1"
"Domain"=""
"Password"="xxxxxxxxxx"
"Username"="rdesktop"
"Computer"="192.168.0.130"

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.

Have fun!

DOWNLOAD:RDP_autologin CPP source EVC4 - (Hits: 2108, size: 123.58 KB) DOWNLOAD:RDP_autologin ARMv4i exe and reg file - (Hits: 2300, size: 4.27 KB)

12 Comments

  1. christophe says:

    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

  2. admin says:

    Hello Christophe

    as VWConfig.ini is not part of this post, please be so kind and just sign up at community.intermec.com. I watch all forums there very often and I or another specialist will answer your question.

    with regards

    Josef

  3. Steve says:

    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.

    Thank you for your help,
    Steve

  4. Fred says:

    Hi Josef,

    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 ?

    Thanks for your help.
    Fred.

  5. admin says:

    Hello Steve

    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.

    Sorry

    and hopefullly you will find some more help at Motorola’s community.

    Josef

  6. admin says:

    Hello Fred

    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.

    Hopefully all will get better with phone 7 enterprise edition.

    sorry

    Josef

  7. admin says:

    Hello ALL

    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:

    0x3B 0x70 // 0x70 – VK_F1
    0x3C 0x71 // 0x71 – VK_F2
    0x3D 0x72 // 0x72 – VK_F3
    0x3E 0x73 // 0x73 – VK_F4
    0x3F 0x74 // 0x74 – VK_F5
    0x40 0x75 // 0x75 – VK_F6
    0x41 0x76 // 0x76 – VK_F7
    0x42 0x77 // 0x77 – VK_F8
    0x43 0x78 // 0x78 – VK_F9
    0x44 0x79 // 0x79 – VK_F10

    Hopefully function keys are accepted by Crossbow RDP and are sent over to the host.

    Crossbow RDP: http://forum.xda-developers.com/showthread.php?t=292895

    regards

  8. Steve says:

    Hi Josef,

    I am using windows mobile 6.1 pocket pc. Where and how should I be installing your application?

  9. Steve says:

    Hey Josef,

    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!

  10. admin says:

    Hello Steve

    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”.

    regards

    Josef

  11. admin says:

    Hello again Steve

    Please try the new Remote Desktop Autologin code at http://www.hjgode.de/wp/2010/06/23/automated-login-for-remote-desktop-mobile-ii/

    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.

    ~Josef

  12. [...] Some days ago I published my RDP_Autologin code: RDP_Autologin [...]

Leave a Reply