How to copy a file via remote desktop connection

In some cases, you may need to copy a file from your local computer to a server, or vice versa, via a remote desktop connection (RDP). In most cases, you can easily do it by exposing your local disks directly to the remote machine. But in some case, this is not possible. For example, where I work now, I have to RDP to one machine, and then from there to a third machine. Copying a log file from that external machine to my local PC for further investigation is then a challenge.

Fortunately, I colleague of mine, Denis Heliszkowski, had a cunning solution. Starting on your source environment, follow these steps:

  1. Copy (Ctrl-C) the file from the Explorer window
  2. Open WordPad and paste the document in there, it will then look something like this:
  3. Now, copy this file again, but now from WordPad.
  4. Switching to your target environment (typically your own PC)
  5. Open WordPad and paste into the empty document
  6. Again, copy this file from WordPad
  7. Open Explorer and paste

Voila – your file has been transferred to your local disk!

This of course also works in the other direction, which can be useful if you need to copy something like the Sysinternal tools to a server which does not have connectivity to the internet.

I must admit that I cannot in detail explain why or how this works. According to Denis, it’s about the file object being converted to a COM object when inserted into a document. I gues the most important thing is that it just works. Smilefjes