Friday, February 10, 2006

 

RDP Auto logon

EMC recently introduced Free VMware Server - http://www.vmware.com/news/releases/server_beta.html. The server allows to run multiple virtual machines on a single box.

I think the news is really welcome among developers. Now even smallest dev shops are equipped with robust and powerful platform for application development and testing. I expect more and better tools for both Microsoft Windows and Linux to come from ISVs in the near future.

Being excited about the news, I was playing with VMware COM API in an attempt to create an application useful for my colleagues and educational for myself. The application I created uses a combination of VMware, sockets and Windows APIs to monitor and backup the VMware Server. During this exercise I came across a couple of issues that needed to be solved. Among other things there was a need to resolve MAC address to IPs and to automatically run terminal client and connect/logon to a remote IP. Resolving MAC to IP was challenging enough to deserve a separate post.

To my surprise, the second problem was not as easy as I expected either. I thought simply executing native Windows Remote Connection client (mstsc.exe) with proper command line parameters will do the job. Unfortunately mstsc does not allow including user id and password in the command line. Suggestions I found on the internet (like use other terminal clients) were not helpful. See more details in the end of this posting. One of the possible solutions was to reverse engineer the way Microsoft hashes the password before saving it in a RDP file and use the same algorithm to create the file. But there was a simpler solution. The solution that finally came to my mind is to start native client and send it required parameters through SendMessage (…,WM_SETTEXT,...) API.

As the result, I created a simple utility that implements this method to script terminal client connections. The utility takes arguments from the command line, passes some of them to the native mstsc and sends additional parameters through the SendMessage API.

This free utility can be downloaded here. It does not require installation and works on Microsoft Windows XP and Microsoft Windows 2003 server. Please read readme.rtf for usage information. I hope the utility will be of help for those who’d like to script Remote Desktop Connection in Microsoft Windows XP and/or Microsoft Windows Server 2003.

This page is powered by Blogger. Isn't yours?