I am looking to write a quick script to send one file (that I change often) from my workstation (windows7 OS) to a remote server (windows server 2012) via the RDP client.

Ideally, I am looking to instantiate the rdpclip.exe process with some arguments. Something like: rdpclip.exe -f [fileToCopyFromLocalToRemote] but to my knowledge (and a brief google search) there is no such equivalent.

Also, I am not looking for any third party tools to do this!


4 Answers 4


You can use PowerShell to put file to clipboard:

Add-Type -AssemblyName System.Windows.Forms
$f = New-Object System.Collections.Specialized.StringCollection
  • 2
    To complete your answer, you need to add that the user needs to also add a script on the remote side to retrieve the copied file. Additionally, these two scripts would have to be in sync or at least responsive to each other. Furthermore, I'm not really sure if this will work and cannot test it myself (security issues on my local machine). If you could test it and address my first two points, this would be the simplest solution by far... Sep 14, 2015 at 11:46

If you intend to stay connected to the RDP session, then you can map a drive on your connection which can make your local drive available to the remote computer. This is on Remote Desktop's Local Resources tab under the More... button.

Once that is enabled, you can make a scheduled task to copy files. You can access the local drives from the special share name \\tsclient\c or whichever drive you are trying to access, as described in this TechNet article. So a sample script that you would run on the remote computer might look something like this:

IF EXIST "\\tsclient\c\Mydir\MyFile" copy /Y "\\tsclient\c\Mydir\MyFile" "C:\Syncrhonized\MyDir\MyFile"

You could put this in as a scheduled task to run every few minutes or so. Be aware of a potential problem if other people remote in to this computer with drive mappings and file structure. Your script won't know which computer is the right one, unless you throw some sort of logic in to check that.

  • I was just writing the similar but you beat me to it. The problem the user has is that you can't map a server drive locally via RDP and RDPClip.exe doesn't have any command line arguments so it can't be used programmatically. The ideal solution would be to VPN to the server and then any programmatic access can be done using native tools such as robocopy. To extend your answer you could recommend a VPN.
    – Kinnectus
    Sep 9, 2015 at 13:28
  • I was trying to stay as close to the original request as possible, since I don't know the nature of the network. It could be that the server is on a firewalled DMZ network only available via RDP. My solution would be two parts - the RDP connection, and a script to run from the remote machine. Please note that \\tsclient is not a traditional server mapping, although it acts like one. It does not require network connectivity other than the RDP session through which it is tunneling. To clarify the answer a bit, tsclient is the literal name to use, not a placeholder. Sep 9, 2015 at 13:36
  • So I cannot map a network drive because the security is locked down. Is there are way to use some native windows process (like rdpclip.exe) to just programmatically do what I can do manually with the clicking (copy and paste). Hypothetically, I see no reason this cannot be accomplished. The user is sending a command somewhere and the OS is interpreting that to actually perform the transfer.... Sep 9, 2015 at 15:25
  • @Matthew: The solution I gave does not involve network drives. It uses the same syntax as a network drive, but it is not one. It all tunnels through the remote desktop session. You will have to manually or otherwise establish a remote desktop session to the computer with drive sharing enabled, but once that is complete, you can connect to \\tsclient\c from the remote computer to get to the local computer's C drive. The link I included has screenshots of the whole process. Try it out. I use this technique frequently to move files to and from a remote machine that is on a secure network. Sep 9, 2015 at 15:36
  • 1
    is there a way to copy from server without mapping the drive? can you provide some resources? Jun 26, 2018 at 2:32

According to my research rdpclip.exe doesn't accept any command line arguments. To use it in order to programmatically copy files is apparently not intended.

Since Windows Vista robocopy is part of every Windows installation. I don't know how you wanna use rdpclip.exe to transfer a file to the remote host. But my first thought was to mount a netshare, use robocopy to transfer a file and dismount the netshare. In an script it will look like:

net use \\Server\Sharename /USER:[username] [passwort]
robocopy [Source] [Destination]
net use \\Servername\Sharename /del
  • Could you give an example? Let's say the server is Sep 19, 2018 at 11:44

As you say that you cannot share your local hard disk with the server, the only sharing mechanism that is left is the clipboard.

If the clipboard is shareable over the RDP connection, you may use the open-source project Clipboard RDC.

This project consists of a very small Java program that is launched on both sides of the connection. The client-side program is used to encode a file and load it to the clipboard, while the server-side program decodes and stores it in a local file. The limitation here is that the file must be small enough to fit on the clipboard.

As it stands, this is more work than you wanted to do. But you can modify this simple program and separate it into two parts :

  1. A client-side program that will accept a file-path as parameter and place the encoded file on the clipboard.
  2. A server-side program that will loop, testing every few seconds for the presence of such a file on the clipboard, decoding and storing it in the folder.

As these will be your own programs that you fully control, you could add features such as adding the destination path to the information that you place on the clipboard, so that this becomes a general-purpose tool for automatically transferring multiple small-enough files from client to server.

  • Without digging too deep into clipboard RDC (which I will do anyway later), is there a native windows command to load something into the clipboard? If there is, I could essentially do just what the FOSS does but natively. Sep 10, 2015 at 11:31
  • I mentioned that project as an example. If you are into Win32 API, then start with the SetClipboardData function. C/C++ will be easier than Java for interfacing with Windows.
    – harrymc
    Sep 10, 2015 at 12:09
  • You could also use the free utility nircmd.exe clipboard commands to load a file into and store from the clipboard.
    – harrymc
    Sep 12, 2015 at 9:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.