Main Webpage


    Terminal Services Bulletin Board
    Links and Downloads
    Matthew Harris' Resume
    Contact the admin


    Disable the X box on the Terminal Services Client
    Change the client version of the Terminal Services Client
    Add the clock to the taskbar through the registry
    Make all processes appear in the Task Manager through a registry hack
    Prevent disconnects and stabilize your terminal services connection
    Fix your TSAdmin application when it becomes nonfunctional on the taskbar
    Disable/Enable all terminal services logons through the registry


    Restrict users to one session and reconnect them
    Share the redirected printer automatically
    Map your client's printer to an LPT port
    Rename client redirected printers
    Restrict users to only one terminal services session
    Automatically connect disconnected users back to their sessions
    Force software license compliance through a script
    How to reset all your TS sessions at once

Hard to Diagnose Problems

    Incorrect IE permissions can disable opening new IE windows

How to make your intermittent or flaky terminal services connection a little more stable

In this article, I'll quickly discuss how using a few registry hacks, you can stabilize your terminal services network connection and reduce the number of disconnected sessions you get from weak WAN connections. These tweaks will also serve to prevent disconnects from occurring when network devices kill off sockets that are idle too long.

ĽA running terminal server that needs to have its connection stabilized
ĽA registry editor, like regedit.exe

Section 1: Indicators:
Many WAN connections can vary in quality and latency, and often times these two characteristics will manifest themselves in disconnected terminal services sessions. By doing two relatively easy registry hacks, you can reduce these disconnects and improve the overall experience of your users.

Section 2: Keep Alives:
In the registry at HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server, create or edit the DWORD value of KeepAliveEnable and set it to 1. This will turn Keep Alives on. This will serve to stabilize the connection by sending 'heartbeat' packets to the client every so often. This will cause an idle connection to be probed every so often just to be sure that the connection is still alive and that the client is still listening on the other side. This will also help prevent disconnects by preventing network devices from killing off sockets that it assumes to be idle. Because terminal services is such a low bandwidth protocol, when a user is idle, no network activity will occur. Some network devices will interpret a connection that is in the idle state for an extended period of time to be a dead connection, and thus will terminate the socket. However, when the user comes out of the idle state, the terminal services client can no longer contact the terminal server because the socket is dead. By turning on Keep Alives, the connection will not appear idle, and therefore the network device will not attempt to terminate the socket.

For more information about Keep Alives, check out this link.

Two other registry entries to look at are at HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\KeepAliveInterval and HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\KeepAliveTime. Both are DWORD entries. These two registry entries typically do not need to be changed, but I've included them here for completeness.

KeepAliveInterval determines the interval separating keep alive retransmissions until a response is received. If a response is received, the delay until the next keep alive transmission is again controlled by the value of KeepAliveTime. The connection will be aborted after the number of retransmissions specified by TcpMaxDataRetransmissions (which will be discussed in the next section) have gone unanswered. KeepAliveInterval is set by default to be 1000, which is one second.

KeepAliveTime controls how often TCP attempts to verify that an idle connection is still intact by sending a keep alive packet. If the remote system is still reachable and functioning, it will acknowledge the keep alive transmission. KeepAliveTime is set by default to be 7,200,000, which is 2 hours.

For more information about KeepAliveInterval and KeepAliveTime, check out this link.

Section 3: TcpMaxDataRetransmissions:

In the registry at HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters, create or edit the DWORD value of TcpMaxDataRetransmissions. By default it is set to 5, but I would recommend doubling that value, to 10. The value of TcpMaxDataRetransmissions is the number of times TCP retransmits an unacknowledged data segment on an existing connection. TCP retransmits data segments until they are acknowledged or until this value expires. Basically, when a client doesn't respond to a packet from the terminal server, the server will attempt to retransmit the packet up to TcpMaxDataRetransmissions number of times. By increasing this value, you are giving the client more time to respond to the server, which will help improve flaky connections or connections with high latency or higher than normal packet loss.

For more information about TcpMaxDataRetransmissions, check out this link.

If you have numerous servers you need to migrate this out to, you can hack this registry entry, export the changes to a .reg file, then silently import it (regedit.exe /q) onto your all your servers.