$theTitle=wp_title(" - ", false); if($theTitle != "") { ?>
About Virtualization, VDI, SBC, Application Compatibility and anything else I feel like
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:
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
If we look at the Window Style we can see the Window is hidden (doesn’t contain WS_VISIBLE):
So we just need to find all windows with this Windows Class and subscribe them to Clipboard Notifications.
The code is simple:
1 2 3 4 5 6 7 8 9 10 11 12 13 | function EnumWindowsProc(hHwnd: HWND; Param:Integer): boolean; stdcall; var ClassName: String; begin SetLength(ClassName, 255); SetLength(ClassName, GetClassName(hHWnd, PChar(ClassName), 255)); if ClassName = 'RdpClipRdrWindowClass' then begin // This is uses to restore the clipboard functionality SetClipboardViewer(hHWND); end; Result := True; end; |
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?
See here for more Terminal Server related articles: https://www.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
20 Responses for "RDP Clipboard Fix"
[…] RemkoWeijnen.nl placed an observative post today on RDP Clipboard FixHere’s a quick excerpt Did you ever loose Clipboard functionality (copy/paste) while working with several Terminal Server … for Citrix (RepairCBDChain.exe), he explains the issue very well on his blog: Windows … has to register itself in the so called clipboard chain. Windows inserts it on top of that chain […]
very handig scripting dude 😉
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!
Works perfectly. Bless you sir!
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?
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?
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?
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.
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
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).
found your site on del.icio.us today and really liked it.. i bookmarked it and will be back to check it out some more later ..
Very nice! It fixes this annoying problem once I run it on the client side!
Has anyone considered a fix for Windows Vista?
This is awesome!!! You just saved me an hour drive into the office to reboot my work system.
You saved me so much time!
Great work
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
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.
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..
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?
[…] of my freeware tools such as LaunchRDP, RDP Password Encryption, Active Directory Excel Addin, RDP Clipboard Fix (well this list can go on and on, see also the Downloads […]
Leave a reply