RDP Clipboard Fix

Did you ever loose Clipboard functionality (copy/paste) while working with several Terminal Server sessions? I think everyone that works a lot with Terminal Server has experienced this from time to time.

It’s caused by badly behaving applications. Dimitry Vostokov wrote a tool to fix this issue for Citrix (RepairCBDChain.exe), he explains the issue very well on his blog:

Windows has a mechanism to notify applications about clipboard changes. An application interested in such notifications has to register itself in the so called clipboard chain. Windows inserts it on top of that chain and that application is responsible to propagate changes down the chain:

rc1.JPG

If 3rd-party application forgets to forward notifications down then we have a broken clipboard chain and clipboard changes are not sent via ICA protocol:

Read more at Dimitry’s Blog: http://citrite.org/blogs/dmitryv/2006/12/09/clipboard-issues-explained/

So how can we fix this for Terminal Server then?
 
MSTSC creates a hidden window with Window Class RdpClipRdrWindowClass, you can observe this with a Window Spy tool such as X-Spy

Clipboard Redirector Window

If we look at the Window Style we can see the Window is hidden (doesn’t contain WS_VISIBLE):

Window Style

So we just need to find all windows with this Windows Class and subscribe them to Clipboard Notifications.

The code is simple:

Using EnumWindows instead of FindWindow (as RepairCBDChain seems to do) has the advantage that it finds multiple windows (when you have multiple sessions) and not just the first.

You can download the compiled version below. If you like it why not leave a comment?

Screenshot RDPFixClip

RDP Clipboard Fix (10652)

See here for more Terminal Server related articles: http://remkoweijnen.nl/blog/topics/terminalserver/

There’s an explanation of this issue at the Microsoft Terminal Services team blog too:
http://blogs.msdn.com/ts/archive/2006/11/16/why-does-my-shared-clipboard-not-work-part-1.aspx
http://blogs.msdn.com/ts/archive/2006/11/20/why-does-my-shared-clipboard-not-work-part-2.aspx

Leave a Reply

  1. Pingback: Personal Computers and Tech News » RDP Clipboard Fix

  2. Fantastic Remko. My clipboard went AWOL on my Vista x64 desktop, nothing to do with remote desktop, and this utility brought it back again. Nice one!

  3. Excuse me, I use Terminal Services on w2k3sp1 and various clients OSes from 2k to XP, using installation mstsc package, provided by Terminal Services on w2k3. Version of RDP is 5.2, most policies are standard, hardware is OK.

    My clipboard works one-way, from local to remote session on terminal server. Can’t copy anything from remote session on terminal server to local computer.

    Kill rdpclip.exe and start it again works well for me, but I can’t do it all the time for all users, who often do not have enough user rights to kill processes, start new, or to call taskmanager.

    I thought that your fix would work fine. But it doesn’t find any RDP clipboard windows, nor on server, nor on server in user’s terminal session, nor on local computer with running terminal session.

    Am I doing anything wrong?

  4. I think you have some application running that breaks the clipboard chain. Since killing and restarting rdpclip on the server temporarily restores it it must be an app that runs on the server. Do you have any strange applications running? Maybe some process that starts on logon or autorun?

  5. Yes, I got a lot of strange applications running, like 3rd party mailserver (MDaemon), 3rd party HTTP server, and lot of alike stuff that I’m not going to remove. Looks like I will be urged to install terminal services on an additional clean server. That sucks.

    But I thought that your prog restores broken clipboard chain (at least for rdpclip). Because as soon as a chain is not broken, there is no need to fix clipboard problems, and there is no need in your prog. Paradox?

  6. Offcourse, the tool is a fix to remedy badly written applications. It’s goal is that you can continue working without having to close and reconnect your terminal session. As you saw it is a client-side fix, serverside you can indeed kill and restart rdpclip.exe.
    It’s never a good idea to combine Terminal Server with other server roles. For instance Mailserver performance is often improved by setting /3GB switch in boot.ini whereas you should *never* do this on Terminal Servers.

  7. When I run RDPFixClip.exe from the command prompt on a Windows Server 2003 in Terminal Server Application Mode is receive the following message:

    RDP Clipboard Fix by Remko Weijnen
    No RDP Clipboard windows were found!
    see http://www.remkoweijnen.nl for more info

  8. Mark, that’s right. The fix is meant for the client side (so where mstsc.exe runs). If you problem is on the server side try killing rdpclip.exe and restarting it. (Sometimes you have to both my fix and the serverside fix in order to restore clipboard).

  9. I freaking love you man!

    For so long do i endure this bug hoping that M$ would fix it with one of the 3 million fixes. But no.

    Thx and best regards from

    Germany

  10. Hi,

    I think this tool is what I need to fix broken clipboard over RDP, but, your download links don’t work – I get a 404 when I try to download anything at all. :( Please fix and kindly drop me an email when working, thanks – there is no other likely fix on the web.

  11. Hi,
    All of your download links are 404’ing.. please email me when fixed so I can download script; thanks. There is no solution anywhere else..

  12. I am RDPing into W2k8 Server from XP Pro SP3. I am losing remote to remote clipboard functionality. Restarting rdpclip did not help. This tool didn’t help either. Any other suggestions?

  13. Pingback: Dear Visitor | Remko Weijnen's Blog (Remko's Blog)