Welcome to MSDN Blogs Sign in | Join | Help

Why does my shared clipboard not work? (Part 2)

(…because the clipboard is a shared system resource)

A few years back we came across a bug where a customer was unable to copy data from a remote session to the local session using the TS shared clipboard. They had a script in the remote session that was doing something like:

 

CopyDataToClipboard(...)

//

// Do something...

//

CopyDataToClipboard(...)

 

The second copy did not always succeed. This was proving to be quite frustrating. After some debugging we discovered the cause…

The Windows system clipboard can only be opened by one application at a time. When it is opened by Application A, attempts by Application B to open it will fail. Hence, B cannot copy any data to the clipboard while A has it open (A might have it open for a valid reason, such as enumerating through the data which is available).

Enter the TS shared clipboard. In order to be notified of when the clipboard has been changed, the TS client (which runs in the local session) and RDPCLIP (which runs in the remote session) register to be part of the clipboard viewer chain associated with their session. When the clipboard is updated, they will be notified of the change. Part of responding to that notification requires opening the clipboard and enumerating through the list of available data types (such as text, graphics or files) and then sending them to the peer component (for example, the TS client will send the list of new data types to RDPCLIP).

Now if you look carefully you can see the race condition which exists in the customer bug. The following time line of events explains it:

 

1.      Script in the remote session opens the clipboard.

2.      Script in the remote session copies data to the clipboard.

3.      Script in the remote session closes the clipboard.

4.      RDPCLIP is notified that the clipboard has been updated.

5.      RDPCLIP opens the clipboard to enumerate through the data types.

6.      RDPCLIP begins to enumerate through the data types.

7.      Script in the remote session tries to open the clipboard.

8.      RDPCLIP finishes enumerating through the data types.

9.      Script in the remote session fails to open the clipboard.

10.  RDPCLIP closes the clipboard.

 

So, what is the solution? Well, in this case we just made the script retry updating the clipboard a few times, sleeping a bit in between each attempt.

However, for Windows Vista (and Longhorn Server) we worked with our friends in the USER32 team and added a new mechanism which allows us to get the list of data types on the clipboard without opening the clipboard. This means that when the clipboard is updated, RDPCLIP (or the TS client) never needs to hold the clipboard open to enumerate the available data types, effectively blowing away this race condition. Another reason to upgrade to the best Windows version ever!

 

Published Monday, November 20, 2006 3:38 PM by termserv

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# re: Why does my shared clipboard not work? (Part 2)

1. Is Microsoft planning to release Vista RDP6 client for XP like it released the XP RDP for other OSes?

2. What about the RDP6 Web Client?

3. For XP, please dont break Remote Assistance when Vista RDP client is installed.

Wednesday, November 22, 2006 11:38 PM by someone

# re: Why does my shared clipboard not work? (Part 2)

Question, this may not be related to this issue, but how did Userdump affect the clipboard in the past?

Thanks!

Thursday, November 23, 2006 12:07 AM by Mike Smith

# re: Why does my shared clipboard not work? (Part 2)

Someone:

(1) Definitely!

(2) The RDP 6.0 redistributable will update mstscax.dll. There will be no separate msrdp.ocx file for RDP 6.0.

(3) Our test team is making sure it will all still work!

Mike:

Can you please explain your question more clearly? What is "userdump" and how have you noticed it affecting the clipboard in the past?

Thursday, November 23, 2006 12:38 AM by Elton Saul

# re: Why does my shared clipboard not work? (Part 2)

This is the utility I am referring to:

http://www.microsoft.com/downloads/details.aspx?FamilyID=E089CA41-6A87-40C8-BF69-28AC08570B7E&displaylang=en

The User Mode Process Dumper (userdump) dumps any running Win32 processes memory image on the fly, without attaching a debugger, or terminating target processes.

A while back, maybe a year ago or so, running Userdump on a terminal server would effectively disable the clipboard functionality all together.

Here is another reference -->

http://support.citrix.com/article/entry.jspa?entryID=6888

I'm not sure if it was related to ICA or RDP, all the document says is "Virtual channels".

Its a moot point now, I was just curious to know how or if it affected rdpclip.

Thank you and Happy Thanksgiving!

--Mike

Thursday, November 23, 2006 3:56 PM by Mike Smith

# re: Why does my shared clipboard not work? (Part 2)

From the Citrix comments about userdump, it appears as though when it ran it broke some virtual channel functionality. Since clipboard redirection uses virtual channels, this would explain why clipboard redirection stopped working.

Sunday, November 26, 2006 2:13 PM by Elton Saul

# Copy and paste inremote session

My friend can mstsc to a remote pc and copy during a session (ex: text file) and paste to his local machine.  Do you know why I would not be able to?

Wednesday, February 07, 2007 2:10 PM by Billy Owensby

# re: Why does my shared clipboard not work? (Part 2)

Elton Saul said:

> (2) The RDP 6.0 redistributable will update mstscax.dll. There will be no separate msrdp.ocx file for RDP 6.0.

Hi,

I run a server that distributes an activeX that wraps msrdp.ocx (RDP5) inside an encryption layer, which allows clients to do RDP5 over SSL.

Any suggestions as to what i need to develop/modify in order to support RDP6 ? (as there's no v6 version of the msrdp activeX component ?

Thanks a lot,

- G

Friday, February 23, 2007 9:26 AM by Guillaume

# re: Why does my shared clipboard not work? (Part 2)

I am running Vista and I'm using visionapp to rdp to machines. I still run into this issue constantly. Is this possibly on the w2k3 server end? I thought it was visonapp at first but I have the same issue with rdp manager as well.

Thanks,

-Joe

Friday, April 06, 2007 1:47 PM by Joe

# re: Why does my shared clipboard not work? (Part 2)

Joe, if server-to-client copy and paste does not work, then the issue is most likely on the server-side. Is this what you are experiencing?

If you are having problems with client-to-server copy and paste, and you are running multiple clients side-by-side, then it is likely you hit a timing bug which I fixed in the client last year - the fix will be in the Vista SP1/LHS RDP client.

Wednesday, April 11, 2007 4:33 PM by Elton Saul

# re: Why does my shared clipboard not work? (Part 2)

Does it mean that RDPCLIP may not get the correct data types of the latest content?

Wednesday, May 16, 2007 11:18 PM by Ye Tian

# re: Why does my shared clipboard not work? (Part 2)

Just one simple question...

If microsoft knows why this is not working, why don't fix it defenitively??! it's realy a frustrating issue when you are overloaded in work and try to copy a simple line of text and it doesn 't work...

Saturday, November 03, 2007 5:29 AM by Pedro Monteiro

# re: Why does my shared clipboard not work? (Part 2)

I can't wait for Vista SP1 just for that reason :)

Thursday, November 22, 2007 7:56 AM by Selcuk

# re: Why does my shared clipboard not work? (Part 2)

Microsoft technitians surely know aboutit, however the management guys dont even know what a clipboard is so why should they pay someone to fix it ? Besides they need all their ressources to push oh so fancy Vista that bring one more ton of stuff that nobody needs

sad but true

JoePing (going maaaaad because of that problem which is wasting my and other peoples lifetime)

Monday, January 07, 2008 5:40 PM by JoePing

# re: Why does my shared clipboard not work? (Part 2)

Hey

I wanted to know if there is any sort of buffer limitation with RDPClip or Clipboard in terms of the amount of data it can hold or transfer at a single go?

Regards

Pushkar Prasad

Thursday, January 31, 2008 4:58 PM by Pushkar Prasad

# re: Why does my shared clipboard not work? (Part 2)

Prasad,

The clipboard goes on the desktop heap, which is fairly small. If I'm interpretting the page I linked at the bottom of this comment correctly, it's about 3MB on 32-bit systems, and 20MB on 64-bit systems. Keep in mind that this heap is used for lots of other things as well, so you won't be able to use all that space.

If you're copying files on the clipboard, the complete contents don't go on the clipboard, so you can easily copy more than 20MB work of files at the same time.

http://blogs.msdn.com/ntdebugging/archive/2007/07/05/desktop-heap-part-2.aspx

Thursday, January 31, 2008 9:36 PM by Eric Holk [MSFT]

# How can I troubleshoot to find the "Bad App" causing clipboard problems?

The has been a lot of talk about badly written apps breaking the Clipboard chain.  We have this happen quite often and I would like to track down which of our apps is causing the problem.  Can you suggest any utilities or methods for troubleshooting and finding the "bad app"?  Maybe a utility for viewing the Clipboard chain so that when it happens I can see what apps are missing from it and which are still there?  If I can find out which app is causing it, I can make a bug report to the app vendor and possibly get a fix.  Other than that, I would have to hope that Microsoft will eventuall come up a with a fix (For XP and 2003).  It sounds like Vista is having quite a few issues with this also... We will be on 2003 Terminal server for at least another year. We run about 30 Terminal servers and this is a consistant complaint from our Users.  It happens randomly and we have yet to find the cause... Seems to be noticed mostly when running office 2003 on terminal server.

Monday, February 25, 2008 7:03 PM by AaronM

# re: Why does my shared clipboard not work? (Part 2)

I can not copy clipboard content now. Ealier it used to work! I dont know what caused it to stop working.

I remote desktop from my vista Media center laptop to win XP box.

I dont seem to have the rdpclip.exe file which everyone seems to be refering to. I searched in windows folder.

Help... this is very annoying.. I have a file open in text editors on both machines and have to copy paste text via it.

Monday, March 10, 2008 6:02 PM by Silicon_chip

# re: Why does my shared clipboard not work? (Part 2)

As many of you, I have a similar issue. Though instead of the copy/paste issue between local RDP and TS-sessions, I'm experiencing this issue in a thinclient environment.

In other words, I have a customer, running a Win2003 Terminal Server. To the server we have about 6-7 thinclient installations. And every now and then, the clipboard fails and they are no longer able to cut/copy n paste whitin the TS-session.

Now, I wrote a little CMD-file that kills and restarts the RDPCLIP.EXE process, but according to customer, it didn't help.

Any tips on what I can/should do?

Tuesday, April 08, 2008 4:08 AM by Office_Sweden

# re: Why does my shared clipboard not work? (Part 2)

I have an issue with only being able to copy text and graphics.  I am trying to locally copy an individual Powerpoint slide and paste it on the remote instance of Powerpoint.  What is pasted is an image of the slide, not the slide and its components.

I tried with and without RDPclip running.

I am using Windows Server Standard 2003 SP2 and Windows XP SP2.  The version of mstsc.exe is 5.1.2600.2180 (xpsp_sp2_rtm.040803-2158)

Thanks, Karl

Thursday, June 26, 2008 10:55 AM by Karl

# re: Why does my shared clipboard not work? (Part 2)

Hi, is there an way to limit the buffer size when copy from local to the remote in an TS seesion to improve security -- Prevent some bug send mass content out ? Is there any tools to do so?

Tuesday, May 12, 2009 10:34 PM by zzz

# re: Why does my shared clipboard not work? (Part 2)

Zzz,

There is no way to limit the size of clipboard data that can be transferred to or from a remote session.

-Elton

Wednesday, May 13, 2009 12:41 AM by Elton

# re: Why does my shared clipboard not work? (Part 2)

From all these comments, the clipboard issues are common in Windows XP and the frustration too.

I would like to someone can help with a solution other than restart the operating system, which works but eventually when the failing application do the same thing, clipboard will stop working for all applications again.

Is there any patch or rdpclip.exe parameter to get the clipboard working again? At this time I have a suspicions application but I would rather to do something to get this clipboard working again.

Any suggestion?

Regards!

Monday, June 22, 2009 10:32 AM by Roger

# re: Why does my shared clipboard not work? (Part 2)

I found something that worked for me without installing any non-official fix:

Killing and restarting rdpclip.exe wasn't working however I knew I had to close an application that wasn't working however there was still a process in the task manager active, so I kill it and tried...nothing...then I killed and restarted again rdpclip and finally worked fine.

So when an application fails for you and clipboard start failing, you can take a look into your process and make sure they all are gone, otherwise restarting clipboard will not work.

Hope helps to someone.

Regards!

Monday, June 22, 2009 10:58 AM by Roger

# re: Why does my shared clipboard not work? (Part 2)

I believe here is the piece which we overlooked for this problem. On remote machine open terminal services Configuration in Administrative tools. Under connections in properties( right click ) of RDP-tcp  you will see a tab called client connections. Make sure the disable flag on clipboad mapping is NOT checked.

Wednesday, July 29, 2009 4:47 PM by js

Leave a Comment

(required) 
required 
(required) 

  
Enter Code Here: Required
 
Page view tracker