Home arrow Articles arrow Customizing the RDP Web Connection
Customizing the RDP Web Connection PDF Print E-mail
User Rating: / 100
PoorBest 
October 08, 2005
The Remote Desktop Web Connection (or “TSWEB” as it is more affectionately known) is a free download from Microsoft’s web site.  It’s kind of a “Citrix Web Interface” for RDP in that it allows you to connect to Terminal Servers and Remote Desktop-enabled computers using Internet Explorer and an ActiveX version of the RDP client.  However its similarities to the Citrix Web Interface end there – there are no published applications, no application load-balancing, etc.  It’s simply a web page with a field for entering a resolvable computer name or IP address and a drop down box for selecting the connection screen size.

The default page that Microsoft includes is pretty basic and it may appear on the surface that the ActiveX version of the RDP client has a pretty limited functionality.   However, there are many settings that can be added or customized in the web page to control the behavior of the ActiveX RDP client to do just about anything the desktop RDP client can.

Remote Desktop Web Connection installs a set of files onto the web server in a directory called /TSWeb (hence, the nickname).   If you open the DEFAULT.HTM file in Notepad and scroll through it, you will notice that it is broken down into three basic sections.  The first section contains VB Script for error messages and form interactions, such as the resolution drop-down box and the Connect button.  The second section includes the HTML code that makes up the form itself and the third section contains additional HTML and VB code for the RDP client detection/installation and connection error handling.  Most of the customizations discussed here deal with the first two sections.

Connecting to the Console of a Server

A new feature of Windows Server 2003 allows you to connect to the server’s console remotely.  With the desktop RDP client, you would append the /console switch to the server name/IP address; however, this switch doesn’t work with the RDP web client.  Instead, it is controlled by the ConnectToServerConsole attribute.  Using the following example, you can create a new checkbox on the web page to toggle this option.

Open DEFAULT.HTM and scroll down to the “LOGIN AREA” section (about half way down), which is where the structure of the page is laid out.  Find the section for “Row 3”.  If you search for “CheckBoxAutoLogon”, it will be the second instance found (the first instance is the code for clicking the “Connect” button).  Below is the HTML code for this section:

<!-- Row 3 -->
<tr>
<!-- Column 3 -->
<td></td>
<!-- Column 4 -->
<td align="bottom">           
<p class=topspace> <input type="checkbox" name="CheckBoxAutoLogon" ID=Check1 value="OFF" onclick = "checkClick"><label for="Check1" ID=SendLogonKey accesskey="l"><ID id=logoninfo>Send <u>l</u>ogon information for this connection </ID></label><br>
<span ID="tableLogonInfo" style="display: none">
            <p align="right" class=topspace>
            <br>
            <ID id=usernamelabel><u>U</u>ser name:</ID>
                <label id=UserNameKey accessKey="U" for="editUserName"><input type="text" name="UserName" id=editUserName size="25"></label><br>
            <ID id=domainlabel><u>D</u>omain:</ID>
          <label id=editDomainKey accessKey="D" for="editDomain">
          <input type="text" name="Domain" id=editDomain size="25"></label></p></span>   
          <input type="submit" id=connectbutton value="Connect" disabled="TRUE" name="ButtonLogin" OnClick=BtnConnect class="button">
</td>
</tr>


Under the <td align="bottom"> tag, insert the following on a single line:

<p class=topspace> <input type="checkbox" name="CheckBoxConsole" ID=Check2 value="OFF"><label for="Check2" ID=ConnectToConsole accesskey="c"><ID id=consoleinfo><u>C</u>onnect to server console</ID></label><br>   

This adds a checkbox above the “Send logon information for this connection” checkbox.  If you want to check your work, save the file and reload the page.  It should now look something like the following:

Figure 1

Now that you have the checkbox in the interface you will need to add the VB code to control it, so find the Sub BtnConnect section in DEFAULT.HTM.  Below is an excerpt of the code that you are looking for:

sub BtnConnect
   Dim serverName
   'server
   if not Document.all.Server.value = "" then
      serverName = Document.all.Server.value
   else
      serverName = Document.location.hostname
   end if


Directly under Sub BtnConnect, insert a new line and add the following code:

   if Document.all.CheckBoxConsole.checked then
   MsRdpClient.AdvancedSettings2.ConnectToServerConsole = TRUE
   end if 
 

Please note that these are three separate lines, unlike the last change you made, which was on a single line.  The new code should look like this:

sub BtnConnect
   if Document.all.CheckBoxConsole.checked then
   MsRdpClient.AdvancedSettings2.ConnectToServerConsole = TRUE
   end if  

   Dim serverName
   'server
   if not Document.all.Server.value = "" then
      serverName = Document.all.Server.value
   else
      serverName = Document.location.hostname
   end if


Save the file and test your connection.  When you check the box “Connect to server console”, you should be connected to session ID 0 when viewed in Terminal Services Manager.

Changing Client Resource Redirection Settings

Another handy change is to turn on disk drive mapping, which can be enabled by changing a parameter in the Device redirection options section:

   'Device redirection options
   MsRdpClient.AdvancedSettings2.RedirectDrives     = FALSE
   MsRdpClient.AdvancedSettings2.RedirectPrinters   = TRUE
   MsRdpClient.AdvancedSettings2.RedirectPorts      = FALSE
   MsRdpClient.AdvancedSettings2.RedirectSmartCards = FALSE


As you can see from the excerpt above, only printer redirection is enabled by default.  Client drive redirection can be enabled by changing the value to TRUE, as can COM port redirection.  On the contrary, if you want to disable printer mapping change the RedirectPrinters value to FALSE.

The example above applies to anyone that connects to a remote computer using this page.  But what if you wanted to have the ability to turn these options on or off on the fly?  You can add additional checkboxes to the web page that would allow you to enable or disable these settings before you connect.  These additions are similar to those you made before to add the Connect to Server Console checkbox.

First, you add the checkboxes to the form itself – this example places them between the Connect to Server Console and Send login information… checkboxes and indents them five spaces:

<p class=topspace> <input type="checkbox" name="CheckBoxConsole" ID=Check2 value="OFF"><label for="Check2" ID=ConnectToConsole accesskey="c"><ID id=consoleinfo><u>C</u>onnect to server console</ID></label><br>     
<p class=topspace>      <input type="checkbox" name="CheckBoxDisk" ID=Check3 CHECKED><label for="Check3" ID=ConnectDisks accesskey="k"><ID id ConnectDisks>Connect Dis<u>k</u> Drives</ID></label><br>
<p class=topspace>      <input type="checkbox" name="CheckBoxPrinter" ID=Check4 CHECKED><label for="Check4" ID=ConnectPrinters accesskey="p"><ID id ConnectPrinters>Connect <u>P</u>rinters</ID></label><br>
<p class=topspace>      <input type="checkbox" name="CheckBoxPort" ID=Check5><label for="Check5" ID=ConnectPorts accesskey="r"><ID id ConnectPorts>Connect Serial Po<u>r</u>ts</ID></label><br>

<p class=topspace> <input type="checkbox" name="CheckBoxAutoLogon" ID=Check1 value="OFF" onclick = "checkClick"><label for="Check1" ID=SendLogonKey accesskey="l"><ID id=logoninfo>Send <u>l</u>ogon information for this connection </ID></label><br>


Next, you add the VB script to the Device redirection options section:

'Device redirection options
    if Document.all.CheckBoxDisk.checked then
      MsRdpClient.AdvancedSettings2.RedirectDrives = TRUE
    else
      MsRdpClient.AdvancedSettings2.RedirectDrives = FALSE
    end if  
    if Document.all.CheckBoxPrinter.checked then
      MsRdpClient.AdvancedSettings2.RedirectPrinters = TRUE
    else
      MsRdpClient.AdvancedSettings2.RedirectPrinters = FALSE
    end if
    if Document.all.CheckBoxPort.checked then
      MsRdpClient.AdvancedSettings2.RedirectPorts = TRUE
    else
      MsRdpClient.AdvancedSettings2.RedirectPorts = FALSE
    end if

   MsRdpClient.AdvancedSettings2.RedirectSmartCards = FALSE


Save the file and check out the page in your browser.  You should see three new checkboxes on the page - Connect Disk Drives, Connect Printers and Connect Serial Ports.

Figure 2

As you can see, Connect Disk Drives and Connect Printers are checked by default.  Removing the word “CHECKED” from the HTML code will change the default state to unchecked.  Now, the next time you connect to a remote computer using this page, you can turn these options on or off to suit your needs.

Customizing Resolution Settings

The resolution size is selected via the drop down box in the web page.  The default selection for the connection is Full Screen.  You can easily limit the options that appear in this box or change the default selection by editing the following section:

<!-- Row 2 -->
<tr>
<!-- Column 3 -->
<td valign="middle">
<p align="right"><label id=sizeKey accessKey="Z" for="comboRes" class="sizespace"><ID id=size>Si<u>z</u>e:</ID></p></td>
<!-- Column 4 -->
<td valign="bottom">  <select size="1" name="comboResolution" id=comboRes class="topspace">
              <option selected value="1"><ID id=option1>Full-screen</ID></option>
              <option value="2"><ID id=option2>640 by 480</ID></option>
              <option value="3"><ID id=option3>800 by 600</ID></option>
              <option value="4"><ID id=option4>1024 by 768</ID></option>
              <option value="5"><ID id=option5>1280 by 1024</ID></option>
              <option value="6"><ID id=option6>1600 by 1200</ID></option>
            </select> </label>
</td>
</tr>


If you want to limit the screen size options that users can choose, you can remove option value=… lines, which will remove those selections from the drop down list on the web page.  You can also alter the default selection by changing option value= to option selected value=.  The following example limits the selections to only 800x600 and 1024x768, and sets the latter to the default.

<!-- Row 2 -->
<tr>
<!-- Column 3 -->
<td valign="middle">
<p align="right"><label id=sizeKey accessKey="Z" for="comboRes" class="sizespace"><ID id=size>Si<u>z</u>e:</ID></p></td>
<!-- Column 4 -->
<td valign="bottom">  <select size="1" name="comboResolution" id=comboRes class="topspace">
              <option value="3"><ID id=option3>800 by 600</ID></option>
              <option selected value="4"><ID id=option4>1024 by 768</ID></option>
            </select> </label>
</td>
</tr>


If you want to customize the actual resolution settings used when connecting to the remote computer, you have to modify the code that passes these settings to the RDP client in the following section: 

   'Resolution
   MsRdpClient.FullScreen = FALSE
   select case document.all.comboResolution.value
   case "1"
      MsRdpClient.FullScreen = TRUE
      resWidth  = screen.width
      resHeight = screen.height
   case "2"
      resWidth  = "640"
      resHeight = "480"
   case "3"
      resWidth  = "800"
      resHeight = "600"
   case "4"
      resWidth  = "1024"
      resHeight = "768"
   case "5"
      resWidth  = "1280"
      resHeight = "1024"
   case "6"
      resWidth  = "1600"
      resHeight = "1200"
   end select
   MsRdpClient.DesktopWidth = resWidth
   MsRdpClient.DesktopHeight = resHeight


The “case “x”” listings above correspond to the “option value=” code in the previous example.  If you want to create a custom resolution setting (i.e. 700x500) you can add in a new “case” here (or change an existing one) and then modify the code to the “comboRes” drop-down box to include that option.

Changing the Connection Port

The MsRdpClient.AdvancedSettings2.RDPPort parameter allows you to customize the port used to connect to the remote computer.  The default TCP port used is 3389, but this can be changed by adding this setting to the Sub BtnConnect section.  For example, adding the following line will set the connection port to 35000:

MsRdpClient.AdvancedSettings2.RDPPort = 35000

As an alternative, you can add a simple input box in the web page that allows you to change the port on a per-connection basis.  The following example adds a text box with a default setting of 3389 with the ability to change the port before you connect. 

Add this code to the Sub BtnConnect section:

MsRdpClient.AdvancedSettings2.RDPPort = Document.all.TextBoxPort.value

Then add this section to the form HTML:

<ID id=portlabel style="display: none">Connection Por<u>t</u>: </ID>
<label id=PortKey accessKey="T" for="textPort"><input type="text" size="2" name="textboxPort" value="3389" id=textPort></label><br>


RDP ActiveX Control Updates

The default web page will automatically detect and install the RDP ActiveX control on the client computer.  However, if a new version of the RDP web client is released and you want to automatically upgrade the version on the end-user’s workstation, you will need to copy the new .CAB file to the /TSWeb directory on the server, and then update the ‘CODEBASE” line in DEFAULT.HTM to include the new version information (notice the use of commas instead of periods).  If the .CAB file name is different be sure to change that as well. 

CODEBASE="msrdp.cab#version=5,2,3790,0"

Once this is done, if a client opens the web page and has an older version of the ActiveX RDP client than the one on indicated by this line, they will automatically be prompted to install the new version on their workstation.

Additional Customizations

The following is a list some additional settings that might come in handy; however, this is only a small fraction of the attributes available for the RDP web client.  For a complete listing of controls and settings, refer to this page on the MSDN web site.

  • MsRdpClient.AdvancedSettings2.EnableAutoReconnect = TRUE will turn on client auto-reconnection.  This attribute is disabled by default.

  • MsRdpClient.ColorDepth = 8 will force the resolution color depth to 256 colors.  This is a “bit” value, so settings this to 16 will configure the color depth to 16-bit color.  You should note that connections to Windows 2000 servers will automatically default to 8-bit color and Windows Server 2003 connections will default to 16-bit color without configuring this attribute.

  • MsRdpClient.AdvancedSettings2.PerformanceFlags will turn off certain features to improve performance.  For instance, a value of 1 will turn off wallpaper, 2 will disable showing window contents while dragging, and 4 will disable menu animations.  To use a combination of restrictions, add the values together.  For example, MsRdpClient.AdvancedSettings2.PerformanceFlags = 5 will disable both wallpaper and menu animations.  A value of 7 will disable all three settings.  There are other performance flags that can be set, so review the documentation on the MSDN web site for a complete list.

  • MsRdpClient.AdvancedSettings2.KeepAliveInterval is the frequency (in milliseconds) at which the client sends keep-alive messages to the server.  Setting this to a value of 300000 will send a keep-alive message every 5 minutes. Keep-alives are disabled by default.

  • MsRdpClient.AdvancedSettings2.SmartSizing = TRUE specifies that the display should be scaled to fit the client’s display without the use of scroll bars (I haven’t used this particular settings, but it does sound as if it could be of good use).

Lastly, you will notice that the first few lines of the form’s code in the LOGIN AREA section are where the default Microsoft logos and titles (win2000l.gif, win2000r.gif, etc.) are configured.  These sections can be customized to add corporate logos, page titles, disclaimers and/or warning messages to change the entire look and feel of the page. 

I’m sure that there are many other customizations that can be made to this page; this article only tackles a few of the more popular settings.  Using the code examples above, you should be able to design a pretty elaborate web page and add checkboxes, drop down lists and text fields for changing these settings on the fly.  If you like, you can download a pre-configured DEFAULT.HTM file here with the above examples already set up.  Also, be sure to check out the MSDN site as the documentation there will provide you with a detailed description of each attribute and its applicable settings.
Last Updated ( December 13, 2005 )
 
< Prev