Copy Files from Remote RDP to Local Machine

WindowsPowershell

Windows Problem Overview


Is there a way I can launch a RDP session to a remote Windows server, and perform a file transfer to the local computer? Versions of the remote Windows Server varies. Ranges anywhere from 2000 to 2008.

I've tried to look up solutions and it seems scattered everywhere. Some suggest using mstsc.exe, others suggest PowerShell / Java / ASP Net. I'm confused. Appreciate some guidance here.

Thanks!

Update Below: 17 Feb 2012

Thanks for all suggestions. Would like to add that the remote servers are securely locked down and I'm not allowed to install SSH servers, FTP servers, or shared drives. The only way for accessing the remote machine is through RDP, and these machines are also on separate VLANs to which only authorised users can use RDP to access these machines. I'm trying to create a script that can help authorised users to download the required files.

Windows Solutions


Solution 1 - Windows

You can map a drive using remote desktop.

Options > Local Resources > More

enter image description here

Solution 2 - Windows

Ctrl + C at the Remote Desktop, and Ctrl + V at local, if you not looking for any automated solution. (Please check RD Config to enable copy and paste)

Solution 3 - Windows

Once you have mapped the drives you want using mstsc, you can use \\tsclient to access the file system of the local machine i.e the Terminal services client from which you have RDP'ed on to the remote box.

If all you are trying to do is copy file from a remote box, just do \\machine\c$\path etc or share the folder and do \\machine\share to get them. RDP is not necessary in this case.

Solution 4 - Windows

Once you have mapped the needed drives as Andy says, you can execute remotely a LOCAL batch file every time you connect specifying it's local path (using \\tsclient\c to refer your local drive) in the Programs tab at RDP properties.
Remember to write cmd /c before that path.
The rdp connection will automatically close once the batch file ends, but you can add the pause command to the end to see what happened during execution.

Connecting this way, you can edit the batch file before connecting.

rdp execute BAT

Solution 5 - Windows

Make sure your remote Machine enabled PSRemoting by running the following command in PowerShell

Enable-PSRemoting –Force

From the client computer, run the following command to establish the connection.

net use "\\{RemoteIP}\c$" "{Password}" /USER:"{Username}" /persistent:no

Here after you can use Copy-Item, Delete-Item over the network.

Copy-Item [PACKAGEPATH]\* \\[COMPUTER]\c$\installers -recurse

Solution 6 - Windows

  1. In Client machine, Run->mstsc.exe-> Local Resources-> enable clipboard.
  2. In remote machine-> windows run command (Windows Key + R).
  3. Open cmd->(Taskkill.exe /im rdpclip.exe) type brackets command
  4. You got "Success", then
  5. Type same command prompt "rdpclip.exe"
  6. Now copy and paste both, its working fine

Solution 7 - Windows

You can copy and paste files over RDP, it works perfectly. See http://www.reddit.com/r/sysadmin/comments/1d6a1o/til_you_can_copy_and_paste_files_over_rdp/ for more info.

Solution 8 - Windows

eug wrote what I thing is an extremely useful comment that seems to have overlooked by everyone:

You can very easily share a single folder by using subst to map it to a drive letter, and then selecting that drive in remote desktop.

Note that it's fairly easily to have problems with this method due to subst performing the mapping only for the user under which it is run.
So I recommend to run everything from a single command prompt:

  1. Open a command prompt (Win+R -> cmd)
  2. Type subst <lettertomap>: <pathtofolder>
  3. Type mstsc (which launches Remote Desktop)

Keep in mind that the subst mappings are not persistent across reboots, of course, so this is mostly convenient for a one-time session of file transfer.

There are actually also other ways to do the mapping, see raymond.cc .

And yes, the mapping does seem to disallow access to the rest of the drive, although I wouldn't bet my life that it doesn't have chroot-like "vulnerabilities" (assuming it is supposed to be secure in the first place).

Solution 9 - Windows

  1. Install dropbox or equivalent cloud storage product and sync needed files that way between computers. Remember, you can allow only certain folders to be synced on specific devices (you don't have to sync the entire dropbox, just the folders you need)

  2. If you are allowed to setup more than one user on the remote server, have a 2nd user and then have user2 session connect rdp session to user1. This will keep the user1's gui alive in the cloud without having to remain logged in to rdp locally.

This video should show you how to implement this 2 user setup on your server to hold an rdp session open. Note that this does 'permanently' use 1 rdp session until you decide to close it. [markdown cannot embed video :( ]

Then use AmmyyAdmin AnyDesk on user1's desktop to connect and manipulate the desktop. This includes using AnyDesk's file manager's ability to browse any folder you need and copy. AnyDesk can be free if you connect via direct IP connection. Most vps servers have dedicated IP addresss or subdomain address so this should not be a problem. Good idea to password protect your AnyDesk login and which IDs have access to unattended remote connections. The AnyDesk file manager is a bit crude, but it works. Their big thing is simplicity and speed.

Note: Use portable mode only on the remote user's desktop; Do NOT fully install AnyDesk. Also, the CPU usage might increase to stream the desktop screen, somewhat related to the size of the RDP window. I am using 1280 x 2048 window with 4 cores and the CPU usage is 22-25% idle or moving things around. This might decrease if there is more video ram or graphics processor on the target server. But, if you only "browse files" (use only the file manager without streaming the desktop), CPU usage >0.3% idle and >1 avg% when transferring files (burst up to 5-6% when the file is finished uploading and the pieces are being finalized).

You'd have to write your own scripts (java, .net, c#/c++, AutoIT, etc) to launch AnyDesk locally and automate the connecting and downloading specific files.

This strategy is a bit more complex, but it should do the job. Not sure why microsoft rdp cannot have some simple, quick file manager like what ammyy admin AnyDesk has; oh well.


Add: Can also use AnyDesk or Teamviewer. Teamviewer became a lot more restrictive on what is considered to be "non commercial use", but Anydesk is secure, much smaller footprint, and if you can have a direct connection doesn't seem to care too much about usage. If you do need a license, it will be much lighter on the wallet.

AnyDesk works flawlessly without any installation required. In fact, if using in a server environment as I described above, no installation is recommended.

Edit: AmmyyAdmin is no longer recommended for several months now due to some security and technical concerns. Added AutoIT as a scripting capability to automate interaction with GUI/nearly any windows function.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionlouis xieView Question on Stackoverflow
Solution 1 - WindowsAndy ArismendiView Answer on Stackoverflow
Solution 2 - WindowsRaymondView Answer on Stackoverflow
Solution 3 - WindowsmanojldsView Answer on Stackoverflow
Solution 4 - WindowsIvan Ferrer VillaView Answer on Stackoverflow
Solution 5 - WindowsDasunView Answer on Stackoverflow
Solution 6 - WindowsRaghulraj PalanisamyView Answer on Stackoverflow
Solution 7 - WindowsboardtcView Answer on Stackoverflow
Solution 8 - WindowsgbrView Answer on Stackoverflow
Solution 9 - WindowsJon GrahView Answer on Stackoverflow